diff options
Diffstat (limited to 'server/server/config.cpp')
-rw-r--r-- | server/server/config.cpp | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp index 264ba22..53386a4 100644 --- a/server/server/config.cpp +++ b/server/server/config.cpp @@ -20,6 +20,7 @@ config::config(const char *pth) vars.log_path = get_string(cfg_str, "LogPath=", "./server.log"); vars.dos_log_path = get_string(cfg_str, "DosLogPath=", "./server_dos.log"); load_proxy_list(); + load_static_proxy_list(); } const int config::get_int(const std::string& data, const char* var, int default_) { @@ -85,13 +86,13 @@ void config::load_proxy_list(char *pth) port = atoi(line.substr(lp1, lp2-lp1).c_str()); lp1 = lp2+2; lp2 = line.find('"', lp1); - country = line.substr(lp1, lp2-lp1).c_str(); + country = line.substr(lp1, lp2-lp1); lp1 = lp2+3; lp2 = line.find('"', lp1); - state = line.substr(lp1, lp2-lp1).c_str(); + state = line.substr(lp1, lp2-lp1); lp1 = lp2+3; lp2 = line.find('"', lp1); - city = line.substr(lp1, lp2-lp1).c_str(); + city = line.substr(lp1, lp2-lp1); } else { @@ -102,13 +103,13 @@ void config::load_proxy_list(char *pth) port = atoi(line.substr(lp1, lp2-lp1).c_str()); lp1 = lp2+2; lp2 = line.find('"', lp1); - country = line.substr(lp1, lp2-lp1).c_str(); + country = line.substr(lp1, lp2-lp1); lp1 = lp2+3; lp2 = line.find('"', lp1); - state = line.substr(lp1, lp2-lp1).c_str(); + state = line.substr(lp1, lp2-lp1); lp1 = lp2+3; lp2 = line.find('"', lp1); - city = line.substr(lp1, lp2-lp1).c_str(); + city = line.substr(lp1, lp2-lp1); } proxy_list.push_back(proxy_entry(login, password, host, port, country, state, city)); p2 = cfg_str.find(';', p1); @@ -125,6 +126,55 @@ void config::load_static_proxy_list(char *pth) config.open(pth, std::fstream::in); std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>()); config.close(); + if(!cfg_str.empty()) + { + std::string::size_type p1 = 0, p2 = 0; + p2 = cfg_str.find(';'); + while(p2 != std::string::npos) + { + std::string line = cfg_str.substr(p1, p2-p1); + p1 = p2+1; + std::string::size_type lp1 = 0, lp2 = 0; + std::string host, login, password, label; + int port = 0, position = 0; + if(line.find('@') != std::string::npos) + { + lp2 = line.find(':', lp1); + login = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find('@', lp1); + password = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find(':', lp1); + host = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find("\x20", lp1); + port = atoi(line.substr(lp1, lp2-lp1).c_str()); + lp1 = lp2+2; + lp2 = line.find('"', lp1); + label = line.substr(lp1, lp2-lp1); + lp1 = lp2+2; + lp2 = line.size(); + position = atoi(line.substr(lp1, lp2-lp1).c_str()); + } + else + { + lp2 = line.find(':'), lp1; + host = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find("\x20", lp1); + port = atoi(line.substr(lp1, lp2-lp1).c_str()); + lp1 = lp2+2; + lp2 = line.find('"', lp1); + label = line.substr(lp1, lp2-lp1); + lp1 = lp2+2; + 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)); + p2 = cfg_str.find(';', p1); + } + } } const int config::ban_time() |