summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAlex Borisov <b0ris@b0ris-satellite.localdomain>2012-01-07 04:45:01 +0200
committerAlex Borisov <b0ris@b0ris-satellite.localdomain>2012-01-07 04:45:01 +0200
commite23f72738a41ada892e8979aaa9cea318e9d941a (patch)
tree4560631e0698bb98a967c79704de0d64a5505c01 /client
parent04a67fd43d8a2d003ea79c7a1f1d94745a78d33c (diff)
FIX turn off generic proxies correctly
Diffstat (limited to 'client')
-rw-r--r--client/Config.cpp1
-rw-r--r--client/Dialog.cpp14
-rw-r--r--client/Proxifier.cpp48
-rw-r--r--client/Proxifier.h6
4 files changed, 63 insertions, 6 deletions
diff --git a/client/Config.cpp b/client/Config.cpp
index ab06fb3..9a32603 100644
--- a/client/Config.cpp
+++ b/client/Config.cpp
@@ -222,7 +222,6 @@ ProxyEntryGeneric* Config::GetGenericProxy(string host, short port)
}
}
return NULL;
-
}
vector<ProxyEntryStatic> Config::GetStaticProxyGuiLine(unsigned line)
diff --git a/client/Dialog.cpp b/client/Dialog.cpp
index 6df4ceb..b08213a 100644
--- a/client/Dialog.cpp
+++ b/client/Dialog.cpp
@@ -138,12 +138,18 @@ void ProxyDialog::ProxyToggled(bool on)
}
if (on)
{
+ vector<Proxy> active = proxifier->GetActiveProxies();
+ for (unsigned i = 0; i < active.size(); i++)
+ {
+ ProxyEntryGeneric* genProxy = cfg->GetGenericProxy(active[i].host, active[i].port);
+ if (genProxy == NULL)
+ {
+ continue;
+ }
+ proxifier->TurnProxyOff(*genProxy);
+ }
proxifier->TurnProxyOn(*proxy);
}
- else
- {
- proxifier->TurnProxyOff(*proxy);
- }
}
void ProxyDialog::StaticProxyToggled(bool on)
diff --git a/client/Proxifier.cpp b/client/Proxifier.cpp
index c3d9d6a..e2185b9 100644
--- a/client/Proxifier.cpp
+++ b/client/Proxifier.cpp
@@ -78,6 +78,51 @@ bool Proxifier::IsOn(string& addr, short port)
return false;
}
+vector<Proxy> Proxifier::GetActiveProxies()
+{
+ vector<Proxy> result;
+ // check for Client chain
+ int chainId = 0;
+ if (!isChainExists(defaultChain, &chainId))
+ {
+ return result;
+ }
+ /**
+ * @todo check if Client chain is enabled
+ */
+ // find proxies in the chain
+ for (unsigned i = 0; i < chainList.size(); i++)
+ {
+ if (chainList[i].name.compare(defaultChain) != 0)
+ {
+ continue;
+ }
+ map<int, bool>::iterator it = chainList[i].proxies.begin();
+ for ( ; it != chainList[i].proxies.end(); it++)
+ {
+ if (!it->second)
+ {
+ continue;
+ }
+ for (unsigned i = 0; i < proxyList.size(); i++)
+ {
+ if (proxyList[i].id != it->first)
+ {
+ continue;
+ }
+ Proxy proxy;
+ proxy.login = proxyList[i].login;
+ proxy.password = proxyList[i].password;
+ proxy.host = proxyList[i].host;
+ proxy.port = proxyList[i].port;
+ proxy.type = proxyList[i].type;
+ result.push_back(proxy);
+ }
+ }
+ }
+ return result;
+}
+
bool Proxifier::TurnProxyOn(Proxy& proxy)
{
if (!valid)
@@ -200,6 +245,9 @@ bool Proxifier::TurnProxyOff(Proxy& proxy)
SetRuleAction(defaultRule, action);
}
RemoveProxyFromChain(proxyId, chainId);
+ /**
+ * @todo remove proxy entry from Proxifier's config
+ */
// update config to reflect last changes
ReadConfig();
break;
diff --git a/client/Proxifier.h b/client/Proxifier.h
index af27b80..3af8ffe 100644
--- a/client/Proxifier.h
+++ b/client/Proxifier.h
@@ -29,7 +29,6 @@ public:
* @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
@@ -41,6 +40,11 @@ public:
*/
bool IsOn(string& addr, short port);
/**
+ * @brief Get list of proxies that is being used by Proxifier right now
+ * @return list of active Proxy records
+ */
+ vector<Proxy> GetActiveProxies();
+ /**
* @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