summaryrefslogtreecommitdiff
path: root/client/Proxy.cpp
diff options
context:
space:
mode:
authorAlex Borisov <borisov.alexandr@rambler.ru>2011-12-21 04:06:39 +0200
committerAlex Borisov <borisov.alexandr@rambler.ru>2011-12-21 04:06:39 +0200
commit2fd868ae27d74305310e5bcd2a81cd07a87659b3 (patch)
tree03141523c396af45835e070e858216633a05fc6b /client/Proxy.cpp
parent2f559d0e236c797e670f47cd70f52cde01092389 (diff)
Generic proxy button work now. Proxy types support
Diffstat (limited to 'client/Proxy.cpp')
-rw-r--r--client/Proxy.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/client/Proxy.cpp b/client/Proxy.cpp
index 46a580e..0854cbb 100644
--- a/client/Proxy.cpp
+++ b/client/Proxy.cpp
@@ -1,4 +1,5 @@
+#include <algorithm>
#include <stdlib.h>
#include "client.h"
#include "Proxy.h"
@@ -8,19 +9,23 @@
**************************************/
//
-// Parse proxy string and set calss members according to it's contents
+// Parse proxy string and set class members according to it's contents
// Some examples:
-// user:password@server.com:1234
-// server.com:1234
+// type://user:password@server.com:1234
+// type://server.com:1234
void Proxy::Parse(std::string entry)
{
Logger::Trace("Parsing proxy string: %s\n", entry.c_str());
-
+ type.clear();
login.clear();
password.clear();
host.clear();
size_t lp1 = 0, lp2 = 0;
+ lp2 = entry.find("://");
+ type = entry.substr(lp1, lp2-lp1);
+ transform(type.begin(), type.end(), type.begin(), toupper);
+ lp1 = lp2 + 3;
if(entry.find('@') != std::string::npos)
{
lp2 = entry.find(':', lp1);
@@ -29,18 +34,11 @@ void Proxy::Parse(std::string entry)
lp2 = entry.find('@', lp1);
password = entry.substr(lp1, lp2-lp1);
lp1 = lp2+1;
- lp2 = entry.find(':', lp1);
- host = entry.substr(lp1, lp2-lp1);
- lp1 = lp2+1;
- port = atoi(entry.substr(lp1).c_str());
- }
- else
- {
- lp2 = entry.find(':', lp1);
- host = entry.substr(lp1, lp2-lp1);
- lp1 = lp2+1;
- port = atoi(entry.substr(lp1).c_str());
}
+ lp2 = entry.find(':', lp1);
+ host = entry.substr(lp1, lp2-lp1);
+ lp1 = lp2+1;
+ port = atoi(entry.substr(lp1).c_str());
}