diff options
Diffstat (limited to 'server/server/config.cpp')
-rw-r--r-- | server/server/config.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp index 967d9fe..1917a13 100644 --- a/server/server/config.cpp +++ b/server/server/config.cpp @@ -4,7 +4,7 @@ config::config(const char *pth) { std::ifstream config; if(!pth) - config.open("./server.cfg", std::fstream::out); + config.open("./server.cfg", std::fstream::in); else config.open(pth, std::fstream::in); std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>()); @@ -48,6 +48,68 @@ const std::string config::get_string(const std::string& data, const char* var, c } return default_; } + +void config::load_proxy_list(char *pth) +{ + std::ifstream config; + if(!pth) + config.open("./proxy_list.cfg", std::fstream::in); + else + 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); + std::string::size_type lp1 = 0, lp2 = 0; + std::string host, login, password, country, state, city; + int port = 0; + if(line.find('@') != std::string::npos) + { + lp2 = line.find(':'); + login = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find('@'); + password = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find(':'); + host = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find("\x20"); + port = atoi(line.substr(lp1, lp2-lp1).c_str()); + lp1 = lp2+2; + lp2 = line.find('"'); + country = line.substr(lp1, lp2-lp1).c_str(); + lp1 = lp2+3; + lp2 = line.find('"'); + state = line.substr(lp1, lp2-lp1).c_str(); + lp1 = lp2+3; + lp2 = line.find('"'); + city = line.substr(lp1, lp2-lp1).c_str(); + proxy_list.push_back(proxy_entry(login, password, host, port, country, state, city)); + } + else + { + } + } + } +} + +void config::load_static_proxy_list(char *pth) +{ + std::ifstream config; + if(!pth) + config.open("./static_proxy_list.cfg", std::fstream::in); + else + config.open(pth, std::fstream::in); + std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>()); + config.close(); +} + const int config::ban_time() { return vars.ban_time; |