summaryrefslogtreecommitdiff
path: root/client/Proxy.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-12-21 20:56:17 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-12-21 20:56:17 +0200
commitac5fac669d8162a81f77cc2f34be85f07e31f8f6 (patch)
tree1251aa0dd6af1b857156f9b2425d057736b260b2 /client/Proxy.cpp
parentbf11b1575ecbc77bf8280733366ae92dfbb31300 (diff)
parent2fd868ae27d74305310e5bcd2a81cd07a87659b3 (diff)
Merge branch 'master' of ssh://sss.chaoslab.ru//home/private_git/proxy_ui
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());
}