summaryrefslogtreecommitdiff
path: root/client/Proxifier.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/Proxifier.h')
-rw-r--r--client/Proxifier.h140
1 files changed, 112 insertions, 28 deletions
diff --git a/client/Proxifier.h b/client/Proxifier.h
index 320ba44..af27b80 100644
--- a/client/Proxifier.h
+++ b/client/Proxifier.h
@@ -7,33 +7,71 @@
#include <string>
#include <QDomElement>
#include <QString>
+#include "Proxy.h"
+
using namespace std;
class QDomDocument;
+class Proxy;
+/**
+ * @brief Special class that represents proxifier's configuration file
+ * @note All operation that turn on/off and add/remove proxies and chain will apply to "Default" rule
+ * All proxies are put into "Client" chain event if it's only one proxy
+ */
class Proxifier
{
public:
/**
+ * @brief Get application-wide singleton instance of Proxifier class
+ * @return pointer to Proxifier singleton
+ */
+ static Proxifier* GetInstance();
+
+ /**
+ * @brief Chack if the current config is valid
+ * @return true if the config is valid or false otherwise
+ * @note you may wish to try ReadConfig() before but if it doesn't help
+ */
+ bool IsValid();
+ /**
+ * @brief Check if certain server is turned on in Proxifier's tules and list
+ */
+ bool IsOn(string& addr, short port);
+ /**
+ * @brief turn proxy on, all traffic will go throught this proxy
+ * @param proxy Proxy class that represents particular proxy
+ * @return true on success or false otherwise
+ * @note adds specified proxy to Proxifier's Proxy list and in "Client" chain<br/>
+ * Also adds "Client" chain to "Default" rule if its not there
+ */
+ bool TurnProxyOn(Proxy& proxy);
+ /**
+ * @brief turn proxy off
+ * @param proxy Proxy class that represents particular proxy
+ * @return true on success or false otherwise<br/>
+ * alse true will be returned even if proxy is not exist in config
+ * @note removes specified proxy from "Client" chain and from Proxy list<br/>
+ * If its the last proxy in client chain then "Default" rule will be resetted to<br/>
+ * send all traffic directly to servers
+ */
+ bool TurnProxyOff(Proxy& proxy);
+
+private:
+ /**
* @brief class representing Proxifier's proxy setting
*/
- class Proxy
+ class ProxifierProxy: public Proxy
{
public:
- string login;
- string password;
- string host;
- string type;
- short port;
- // proxifier-specific fields
int id;
short option;
bool useAuth; // whether to authenticate on server
bool emptyAuth; // self-closing auth (for Proxifier it means to use current login+pass)
- Proxy();
+ ProxifierProxy();
};
/**
@@ -92,26 +130,18 @@ public:
Rule();
};
-
- static Proxifier* GetInstance();
-
/**
- * @brief Chack if the current config is valid
- * @return true if the config is valid or false otherwise
- * @note you may wish to try ReadConfig() before but if it doesn't help
+ * @brief XML indentation level
*/
- bool IsValid();
+ static const int indent = 4;
/**
- * @brief read Proxifier config from file and parse it
- * @note you should check IsValid() method to get to know if the config is valid
+ * @brief default chain name to add proxies to
*/
- void ReadConfig();
-
-private:
+ static string defaultChain;
/**
- * @brief XML indentation level
+ * @brief default rule name to add proxies to
*/
- static const int indent = 4;
+ static string defaultRule;
/**
* @brief pointer to sigleton instance
*/
@@ -120,14 +150,37 @@ private:
* @brief XML file name to read data from
*/
QString filename;
+ /**
+ * @brief indicates whether config valid or not
+ */
bool valid;
- vector<Proxy> proxyList;
+ vector<ProxifierProxy> proxyList;
vector<Chain> chainList;
vector<Rule> ruleList;
Proxifier();
+ /**
+ * @brief read Proxifier config from file and parse it
+ * @note you should check IsValid() method to get to know if the config is valid
+ */
+ void ReadConfig();
+ /**
+ * @brief read ProxyList section in Proxifier's config
+ * @param root root DOM element
+ * @return true on success or false otherwise
+ */
bool ReadProxyList(QDomElement& root);
+ /**
+ * @brief read ChainList section in Proxifier's config
+ * @param root root DOM element
+ * @return true on success or false otherwise
+ */
bool ReadChainList(QDomElement& root);
+ /**
+ * @brief read RuleList section in Proxifier's config
+ * @param root root DOM element
+ * @return true on success or false otherwise
+ */
bool ReadRuleList(QDomElement& root);
/**
* @brief gets the next valid ID fo proxy/chain
@@ -141,28 +194,28 @@ private:
* id new proxy id will be set there
* @return true on success or false otherwise
*/
- bool AddProxy(Proxy& proxy, int* id);
+ bool AddProxy(ProxifierProxy& proxy, int* id);
/**
* @brief add new chain to proxifier config
* @param name the name of the chain
* id new chain id
* @return true on success or false otherwise
*/
- bool AddChain(string& name, int *id);
+ bool AddChain(string& name, int* id);
/**
* @brief add proxy to proxy chain
* @param proxyId proxy ID to add to proxy chain
* chainId chain ID to add proxy to
* @return true on success or false otherwise
*/
- bool AddChainProxy(int proxyId, int chainId);
+ bool AddProxyToChain(int proxyId, int chainId);
/**
* @brief remove proxy from proxy chain
* @param proxyId proxy ID to remove to proxy chain
* chainId chain ID to remove proxy from
* @return true on success or false otherwise
*/
- bool RemoveChainProxy(int proxyId, int chainId);
+ bool RemoveProxyFromChain(int proxyId, int chainId);
/**
* @brief add new rule to Proxifier config
* @param rule rule class representing Proxifier's rule entry
@@ -170,11 +223,42 @@ private:
*/
bool AddRule(Rule& rule);
/**
+ * @brief modify action on existing rule
+ * @param name name of the rule to modify
+ * action action name to set to
+ * actId id of action target (if applicable)
+ * @return true on success or false otherwise
+ */
+ bool SetRuleAction(string& name, string& action, int actId = -1);
+ /**
* @brief remove rule to Proxifier config
* @param name name of the rule to remove from Rule list
* @return true on success or false otherwise
*/
- bool RemoveRule(string name);
+ bool RemoveRule(string& name);
+ /**
+ * @brief Check if certain proxy address exists in Proxifier's Proxy list
+ * @param addr proxy address to check for
+ * port proxy port to check for
+ * id if proxy exist then there'll be it's id number otherwise this value is undetermined
+ * @return true if proxy exist or false otherwise
+ * @note DNS names are not resolved and not compared to IPs<br/>
+ * proxies are compared only by checking address and port values
+ */
+ bool isProxyExists(string& addr, short port, int* id = NULL);
+ /**
+ * @brief Check if certain chain exisis in Proxifier's Chain list
+ * @param name chain name to check for
+ * id if chain exist then there'll be it's id number otherwise this value is undetermined
+ * @return true if chain exist or false otherwise
+ */
+ bool isChainExists(string& name, int* id = NULL);
+ /**
+ * @brief Check if certain rule exists
+ * @param name rule name to check for
+ * @return true if rule exist or false otherwise
+ */
+ bool isRuleExists(string& name);
};
#endif