#include "headers.h" extern config *cfg; using namespace rapidxml; bool p_load_proxy_list(std::list *list, char *path) { std::ifstream file; if(!path) file.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); else file.open(path, std::ios::in); if(file.is_open()) { std::string data((std::istreambuf_iterator(file)), std::istreambuf_iterator()); file.close(); xml_document<> doc; xml_node<> *proxy_list = doc.first_node()->first_node("ProxyList"); if(!proxy_list) return false; for(xml_node<> *node = proxy_list->first_node("Proxy"); node; node = node->next_sibling("Proxy")) { config::p_proxy_entry e; e.id = atoi(node->first_attribute("id")->value()); std::string type = node->first_attribute("type")->value(); if(type == "HTTPS") e.type = config::HTTPS; if(type == "SOCKS4") e.type = config::SOCKS4; if(type == "SOCKS5") e.type = config::SOCKS5; e.host = node->first_node("Address")->value(); e.port = atoi(node->first_node("Port")->value()); e.options = atoi(node->first_node("Options")->value()); xml_node<> *auth = node->first_node("Authentication"); if(auth) { e.enable_auth = atoi(auth->first_attribute("Enabled")->value()); e.login = auth->first_node("Username")->value(); e.password = auth->first_node("Password")->value(); //TODO: detect kind of hash, decrypt (needed for set auth settings in proxy list) } list->push_back(e); } if(!list->empty()) return true; // succesfully loaded some entries } return false; } bool p_load_proxy_chains(std::list *list, char *path) { std::ifstream file; if(!path) file.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); else file.open(path, std::ios::in); if(file.is_open()) { std::string data((std::istreambuf_iterator(file)), std::istreambuf_iterator()); file.close(); xml_document<> doc; xml_node<> *chain_list = doc.first_node()->first_node("ChainList"); if(!chain_list) return false; for(xml_node<> *node = chain_list->first_node("Chain"); node; node = node->next_sibling("Chain")) { config::p_proxy_chain c; c.id = atoi(node->first_attribute("id")->value()); c.name = node->first_node("Name")->value(); for(xml_node<> *proxy = node->first_node("Proxy"); proxy; proxy = proxy->next_sibling("Proxy")) { config::p_proxy_chain::chain_entry e; e.enabled = atoi(proxy->first_attribute("enabled")->value()); e.id = atoi(proxy->value()); c.chain.push_back(e); } list->push_back(c); } if(!list->empty()) return true; } return false; } bool p_save_proxy_list(std::list *list, char *path) { } bool p_save_proxy_chains(std::list *list, char *path) { }