summaryrefslogtreecommitdiff
path: root/server/server/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/server/config.cpp')
-rwxr-xr-xserver/server/config.cpp91
1 files changed, 87 insertions, 4 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp
index 7a1c80b..7e46bdc 100755
--- a/server/server/config.cpp
+++ b/server/server/config.cpp
@@ -198,7 +198,7 @@ void config::load_proxy_list(char *pth)
if(!cfg_str.empty())
{
std::string::size_type p1 = 0, p2 = 0, l = 1;
- if(cfg_str.find("\r\n") != std::string::npos)
+ if(cfg_str.rfind("\r\n") != std::string::npos)
l = 2;
p2 = cfg_str.find(';');
while(p2 != std::string::npos)
@@ -207,9 +207,21 @@ void config::load_proxy_list(char *pth)
p1 = p2+l+1;
std::string::size_type lp1 = 0, lp2 = 0;
std::string host, login, password, country, state, city;
+ proxy_type type = UNKNOWN;
int port = 0;
if(line.find('@') != std::string::npos)
{
+ lp2 = line.find("//:", lp1);
+ std::string s_type = line.substr(lp1, lp2-lp1);
+ if(s_type == "http")
+ type = HTTP;
+ else if(s_type == "https")
+ type = HTTPS;
+ else if(s_type == "socks4")
+ type = SOCKS4;
+ else if(s_type == "socks5")
+ type = SOCKS5;
+ lp1 = lp2+3;
lp2 = line.find(':', lp1);
login = line.substr(lp1, lp2-lp1);
lp1 = lp2+1;
@@ -233,6 +245,17 @@ void config::load_proxy_list(char *pth)
}
else
{
+ lp2 = line.find("//:", lp1);
+ std::string s_type = line.substr(lp1, lp2-lp1);
+ if(s_type == "http")
+ type = HTTP;
+ else if(s_type == "https")
+ type = HTTPS;
+ else if(s_type == "socks4")
+ type = SOCKS4;
+ else if(s_type == "socks5")
+ type = SOCKS5;
+ lp1 = lp2+3;
lp2 = line.find(':', lp1);
host = line.substr(lp1, lp2-lp1);
lp1 = lp2+1;
@@ -248,7 +271,7 @@ void config::load_proxy_list(char *pth)
lp2 = line.find('"', lp1);
city = line.substr(lp1, lp2-lp1);
}
- proxy_list.push_back(proxy_entry(login, password, host, port, country, state, city));
+ proxy_list.push_back(proxy_entry(login, password, host, port, country, state, city, type));
p2 = cfg_str.find(';', p1);
}
}
@@ -270,7 +293,7 @@ void config::load_static_proxy_list(char *pth)
if(!cfg_str.empty())
{
std::string::size_type p1 = 0, p2 = 0, l = 1;
- if(cfg_str.find("\r\n") != std::string::npos)
+ if(cfg_str.rfind("\r\n") != std::string::npos)
l = 2;
p2 = cfg_str.find(';');
while(p2 != std::string::npos)
@@ -279,9 +302,20 @@ void config::load_static_proxy_list(char *pth)
p1 = p2+l+1;
std::string::size_type lp1 = 0, lp2 = 0;
std::string host, login, password, label;
+ proxy_type type = UNKNOWN;
int port = 0, position = 0;
if(line.find('@') != std::string::npos)
{
+ lp2 = line.find("//:", lp1);
+ std::string s_type = line.substr(lp1, lp2-lp1);
+ if(s_type == "http")
+ type = HTTP;
+ else if(s_type == "https")
+ type = HTTPS;
+ else if(s_type == "socks4")
+ type = SOCKS4;
+ else if(s_type == "socks5")
+ type = SOCKS5;
lp2 = line.find(':', lp1);
login = line.substr(lp1, lp2-lp1);
lp1 = lp2+1;
@@ -302,6 +336,16 @@ void config::load_static_proxy_list(char *pth)
}
else
{
+ lp2 = line.find("//:", lp1);
+ std::string s_type = line.substr(lp1, lp2-lp1);
+ if(s_type == "http")
+ type = HTTP;
+ else if(s_type == "https")
+ type = HTTPS;
+ else if(s_type == "socks4")
+ type = SOCKS4;
+ else if(s_type == "socks5")
+ type = SOCKS5;
lp2 = line.find(':'), lp1;
host = line.substr(lp1, lp2-lp1);
lp1 = lp2+1;
@@ -314,7 +358,7 @@ void config::load_static_proxy_list(char *pth)
lp2 = line.size();
position = atoi(line.substr(lp1, lp2-lp1).c_str());
}
- static_proxy_list.push_back(static_proxy_entry(login, password, host, port, label, position));
+ static_proxy_list.push_back(static_proxy_entry(login, password, host, port, label, position, type));
p2 = cfg_str.find(';', p1);
}
}
@@ -377,6 +421,45 @@ void config::load_deleted_list(char* pth)
}
}
+std::list<config::p_proxy_entry> *config::make_p_proxy_list()
+{
+ p_proxy_list.clear();
+ if(!static_proxy_list.empty())
+ {
+ for(std::list<config::static_proxy_entry>::iterator i = static_proxy_list.begin(), end = static_proxy_list.end(); i != end; ++i)
+ {
+ p_proxy_entry e;
+ e.enable_auth = (!i->login.empty())?true:false;
+ e.host = i->host;
+ e.id = !p_proxy_list.empty()?p_proxy_list.back().id+1:100;
+ e.login = i->login;
+ e.options = 0;
+ e.password = i->password;
+ e.port = i->port;
+ e.type = i->type;
+ p_proxy_list.push_back(e);
+ }
+ }
+
+ if(!proxy_list.empty())
+ {
+ for(std::list<config::proxy_entry>::iterator i = proxy_list.begin(), end = proxy_list.end(); i != end; ++i)
+ {
+ p_proxy_entry e;
+ e.enable_auth = (!i->login.empty())?true:false;
+ e.host = i->host;
+ e.id = !p_proxy_list.empty()?p_proxy_list.back().id+1:100;
+ e.login = i->login;
+ e.options = 0;
+ e.password = i->password;
+ e.port = i->port;
+ e.type = i->type;
+ p_proxy_list.push_back(e);
+ }
+ }
+ return &p_proxy_list;
+}
+
const int config::ban_time()
{
return vars.ban_time;