summaryrefslogtreecommitdiff
path: root/client/proxy.cpp
blob: 1857231af5d0d0f9adf8bb8f11f7fd502f85f428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

#include <stdlib.h>
#include "proxy.h"

/**************************************
 * Proxy methods
 **************************************/
 
 //
 // Parse proxy string and set calss members according to it's contents
 // Some examples:
 //		user:password@server.com:1234
 //		server.com:1234
void Proxy::Parse(std::string entry)
{
	login.clear();
	password.clear();
	host.clear();
	
	size_t lp1 = 0, lp2 = 0;
	int port = 0;
	if(entry.find('@') != std::string::npos)
	{
		lp2 = entry.find(':', lp1);
		login = entry.substr(lp1, lp2-lp1);
		lp1 = lp2+1;
		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());
	}
}


/**************************************
 * ProxyEntry methods
 **************************************/
void ProxyEntry::Parse(std::string entry)
{
	country.clear();
	state.clear();
	city.clear();
	
	size_t lp1 = 0, lp2 = 0;
	//extract Proxy part
	lp2 = entry.find(" ", lp1);
	std::string proxy = entry.substr(lp1, lp2-lp1);
	Proxy::Parse(proxy);
	// extract country, city and state
	lp1 = lp2+2;
	lp2 = entry.find('"', lp1);
	country = entry.substr(lp1, lp2-lp1);
	lp1 = lp2+3;
	lp2 = entry.find('"', lp1);
	state = entry.substr(lp1, lp2-lp1);
	lp1 = lp2+3;
	lp2 = entry.find('"', lp1);
	city = entry.substr(lp1, lp2-lp1);
}
 
 
/**************************************
 * StaticProxyEntry methods
 **************************************/
void ProxyEntryStatic::Parse(std::string entry)
{
 
}