|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the QLop Software
|
|
|
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/*-- Author : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@member.fsf.org
|
|
|
----------------------------------------------------------------------------*/
|
|
|
#ifndef PROXYPACPARSER_H
|
|
|
#define PROXYPACPARSER_H
|
|
|
|
|
|
#include <QObject>
|
|
|
#include <QScriptContext>
|
|
|
#include <QScriptEngine>
|
|
|
|
|
|
class ProxyPacParser : public QObject
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
Q_PROPERTY( QString PacFile WRITE setPacFile )
|
|
|
|
|
|
public:
|
|
|
ProxyPacParser(QObject *parent = 0);
|
|
|
~ProxyPacParser();
|
|
|
void setPacFile(const QString& fileContent);
|
|
|
Q_SCRIPTABLE QString findProxyForUrl( const QString &url, const QString &host );
|
|
|
|
|
|
signals:
|
|
|
|
|
|
public slots:
|
|
|
private:
|
|
|
|
|
|
//Hostname based conditions:
|
|
|
static QScriptValue isPlainHostName( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue dnsDomainIs( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue localHostOrDomainIs( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue isResolvable( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue isInNet( QScriptContext *context, QScriptEngine *engine );
|
|
|
|
|
|
//Related utility functions:
|
|
|
static QScriptValue dnsResolve( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue myIpAddress( QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue dnsDomainLevels( QScriptContext *context, QScriptEngine *engine );
|
|
|
|
|
|
//URL/hostname based conditions:
|
|
|
static QScriptValue shExpMatch( QScriptContext *context, QScriptEngine *engine );
|
|
|
|
|
|
// Time based conditions:
|
|
|
static QScriptValue weekdayRange(QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue dateRange(QScriptContext *context, QScriptEngine *engine );
|
|
|
static QScriptValue timeRange(QScriptContext *context, QScriptEngine *engine );
|
|
|
|
|
|
/*
|
|
|
* Implementation of Microsoft's IPv6 Extension for PAC
|
|
|
*
|
|
|
* Documentation:
|
|
|
* http://msdn.microsoft.com/en-us/library/gg308477(v=vs.85).aspx
|
|
|
* http://msdn.microsoft.com/en-us/library/gg308478(v=vs.85).aspx
|
|
|
* http://msdn.microsoft.com/en-us/library/gg308474(v=vs.85).aspx
|
|
|
* http://blogs.msdn.com/b/wndp/archive/2006/07/13/ipv6-pac-extensions-v0-9.aspx
|
|
|
*
|
|
|
* taken from KDE KIO kpac source code :)
|
|
|
*/
|
|
|
static QScriptValue isResolvableEx(QScriptContext *context, QScriptEngine *engine);
|
|
|
static QScriptValue isInNetEx(QScriptContext *context, QScriptEngine *engine);
|
|
|
static QScriptValue dnsResolveEx(QScriptContext *context, QScriptEngine *engine);
|
|
|
static QScriptValue myIpAddressEx(QScriptContext *context, QScriptEngine *engine);
|
|
|
static QScriptValue sortIpAddressList(QScriptContext *context, QScriptEngine *engine);
|
|
|
|
|
|
|
|
|
QScriptEngine* engine;
|
|
|
|
|
|
static int findString(const QString &s, const char * const *values);
|
|
|
static const QDateTime getTime(QScriptContext *context);
|
|
|
};
|
|
|
|
|
|
#endif // PROXYPACPARSER_H
|
|
|
|