diff options
author | Alex Borisov <b0ric.alex@gmail.com> | 2012-02-03 00:48:22 +0200 |
---|---|---|
committer | Alex Borisov <b0ric.alex@gmail.com> | 2012-02-03 00:48:22 +0200 |
commit | 5797cb8347f787121c286c91d300fdda9ab65d56 (patch) | |
tree | 1f34fa8fade09a408fe2c079becad9434e767db2 | |
parent | 679ddcbe2580c1784fba065acef5b6766d926eb1 (diff) | |
parent | f1e39c6d902c0783b9f99551f4d2e8d6bf11ad05 (diff) |
Merge branch 'master' of ssh://sss.chaoslab.ru/home/private_git/proxy_ui
-rw-r--r-- | server/server/Makefile.mingw32 | 2 | ||||
-rwxr-xr-x | server/server/p_process.cpp | 16 | ||||
-rwxr-xr-x | server/server/p_process.h | 6 | ||||
-rwxr-xr-x | server/server/p_xml.cpp | 245 | ||||
-rwxr-xr-x | server/server/p_xml.h | 12 |
5 files changed, 1 insertions, 280 deletions
diff --git a/server/server/Makefile.mingw32 b/server/server/Makefile.mingw32 index 11a6139..277cff9 100644 --- a/server/server/Makefile.mingw32 +++ b/server/server/Makefile.mingw32 @@ -1,5 +1,5 @@ all: - i686-pc-mingw32-g++ -c *.cpp -I/home/sss/temp/mingw/usr/i686-pc-mingw32/include -I../../libs/rapidxml-1.13 -O2 -pipe -msse -fomit-frame-pointer -DWIN32 -D_WIN32 -DBOOST_THREAD_USE_LIB + i686-pc-mingw32-g++ -c *.cpp -I/home/sss/temp/mingw/usr/i686-pc-mingw32/include -O2 -pipe -msse -fomit-frame-pointer -DWIN32 -D_WIN32 -DBOOST_THREAD_USE_LIB i686-pc-mingw32-g++ -o server.exe *.o -lssl -lcrypto -lwldap32 -lcurl -lidn -lintl -liconv -lssh2 -lwldap32 -lz -lgnutls -lnettle -lhogweed -lgmp -lz -lssh2 -lgcrypt -lgpg-error -lboost_system-mt -lboost_date_time-mt -lboost_thread_win32-mt -lboost_random-mt -lboost_filesystem-mt -lmswsock -lws2_32 -lgdi32 -lz -Wl,-O1 -s clean: rm *.o diff --git a/server/server/p_process.cpp b/server/server/p_process.cpp deleted file mode 100755 index 1d50044..0000000 --- a/server/server/p_process.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "headers.h"
-/*
-extern config *cfg;
-
-bool p_start(char *path)
-{
- Poco::Process *p = new Poco::Process;
- if(!path)
- p->launch(cfg->proxifier_path()+"proxifier.exe", Poco::Process::Args());
- else
- p->launch(path, Poco::Process::Args());
- if(p->id() > 0)
- return true;
- return false;
-}
-*/
\ No newline at end of file diff --git a/server/server/p_process.h b/server/server/p_process.h deleted file mode 100755 index 02fa070..0000000 --- a/server/server/p_process.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef P_PROCESS_H
-#define P_PROCESS_H
-/*
-bool p_start(char *path = NULL);
-*/
-#endif
\ No newline at end of file diff --git a/server/server/p_xml.cpp b/server/server/p_xml.cpp deleted file mode 100755 index 3d41428..0000000 --- a/server/server/p_xml.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include "headers.h"
-/*
-using namespace rapidxml;
-
-bool p_load_proxy_list(std::list<config::p_proxy_entry> *list, config *cfg, const char *path)
-{
- if(!list->empty())
- list->clear();
- std::ifstream file;
- if(!path)
- file.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); //TODO: handle different locations
- else
- file.open(path, std::ios::in);
- if(file.is_open())
- {
- std::string data((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
- file.close();
- xml_document<> doc;
- doc.parse<0>(doc.allocate_string(data.c_str()));
- 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 == "HTTP")
- e.type = config::HTTP;
- 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<config::p_proxy_chain> *list, config *cfg, const char *path)
-{
- if(!list->empty())
- list->clear();
- std::ifstream file;
- if(!path)
- file.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); //TODO: handle different locations
- else
- file.open(path, std::ios::in);
- if(file.is_open())
- {
- std::string data((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
- file.close();
- xml_document<> doc;
- doc.parse<0>(doc.allocate_string(data.c_str()));
- 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<config::p_proxy_entry> *list, config *cfg, const char *path)
-{
- std::list<config::p_proxy_entry> *p_list = cfg->make_p_proxy_list();
- if(p_list->empty())
- return false;
- std::ifstream infile;
- if(!path)
- infile.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); //TODO: handle different locations
- else
- infile.open(path, std::ios::in);
- if(infile.is_open())
- {
- std::string data((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>());
- infile.close();
- xml_document<> doc;
- doc.parse<0>(doc.allocate_string(data.c_str()));
- xml_node<> *proxy_list = doc.first_node()->first_node("ProxyList");
- if(proxy_list)
- {
- proxy_list->remove_all_nodes();
- proxy_list->remove_all_attributes();
- }
- else
- {
- proxy_list = doc.allocate_node(node_element, "ProxyList");
- doc.append_node(proxy_list);
- }
- for(std::list<config::p_proxy_entry>::iterator i = p_list->begin(), end = p_list->end(); i != end; ++i)
- {
- xml_node<> *proxy = doc.allocate_node(node_element, "Proxy");
- char val[8];
- snprintf(val, 7, "%d", i->id);
- xml_attribute<> *attr = doc.allocate_attribute("id", doc.allocate_string(val));
- proxy->append_attribute(attr);
- std::string type;
- switch(i->type)
- {
- case config::HTTP:
- type = "HTTP";
- break;
- case config::HTTPS:
- type = "HTTPS";
- break;
- case config::SOCKS4:
- type = "SOCKS4";
- break;
- case config::SOCKS5:
- type = "SOCKS5";
- break;
- }
- attr = doc.allocate_attribute("type", doc.allocate_string(type.c_str()));
- proxy->append_attribute(attr);
- xml_node<> *node = doc.allocate_node(node_element, "Address");
- node->value(doc.allocate_string(i->host.c_str()));
- proxy->append_node(node);
- node = doc.allocate_node(node_element, "Port");
- snprintf(val, 7, "%d", i->port);
- node->value(doc.allocate_string(val));
- proxy->append_node(node);
- node = doc.allocate_node(node_element, "Options");
- snprintf(val, 7, "%d", i->options);
- node->value(doc.allocate_string(val));
- proxy->append_node(node);
- if(!i->login.empty())
- {
- xml_node<> *auth = doc.allocate_node(node_element, "Authentication");
- attr = doc.allocate_attribute("enabled", i->enable_auth?"true":"false");
- auth->append_attribute(attr);
- node = doc.allocate_node(node_element, "Username");
- node->value(doc.allocate_string(i->login.c_str()));
- auth->append_node(node);
- node = doc.allocate_node(node_element, "Password");
- node->value(doc.allocate_string(i->password.c_str()));
- auth->append_node(node);
- proxy->append_node(auth);
- }
- proxy_list->append_node(proxy);
- }
- std::ofstream outfile;
- if(!path)
- outfile.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str()); //TODO: handle different locations
- else
- outfile.open(path);
- if(outfile.is_open())
- {
- outfile<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
- outfile<<doc;
- return true;
- }
- }
- return false;
-}
-
-bool p_sset_default_rule(config::p_proxy_entry *entry, config *cfg, const char *path)
-{
- std::list<config::p_proxy_entry> *p_list = cfg->make_p_proxy_list();
- if(p_list->empty())
- return false;
- std::ifstream infile;
- if(!path)
- infile.open(std::string(cfg->proxifier_path()+"/Default/Default.ppx").c_str(), std::ios::in); //TODO: handle different locations
- else
- infile.open(path, std::ios::in);
- if(infile.is_open())
- {
- std::string data((std::istreambuf_iterator<char>(infile)), std::istreambuf_iterator<char>());
- infile.close();
- xml_document<> doc;
- doc.parse<0>(doc.allocate_string(data.c_str()));
- xml_node<> *rule_list = doc.first_node()->first_node("RuleList");
- if(!rule_list)
- {
- rule_list = doc.allocate_node(node_element, "RuleList");
- doc.append_node(rule_list);
- }
- xml_node<> *default_rule = NULL;
- for(xml_node<> *rule = rule_list->first_node("Chain"); rule; rule = rule->next_sibling("Chain"))
- {
- xml_node<> *name = rule->first_node("Name");
- if(name)
- {
- if(!strcmp(name->value(), "Default"))
- {
- default_rule = rule;
- break;
- }
- }
- }
- char val[8];
- snprintf(val, 7, "%d", entry->id);
- if(default_rule) //no validation here, assuming valid config
- {
- default_rule->first_attribute("enabled")->value("true");
- xml_node<> *action = default_rule->first_node("Action");
- action->first_attribute("type")->value("Proxy");
- action->value(doc.allocate_string(val));
- }
- else
- {
- default_rule = doc.allocate_node(node_element, "Rule");
- rule_list->append_node(default_rule);
- default_rule->append_attribute(doc.allocate_attribute("enabled", "true"));
- default_rule->append_node(doc.allocate_node(node_element, "Name", "Default"));
- xml_node<> *action = doc.allocate_node(node_element, "Action", doc.allocate_string(val));
- action->append_attribute(doc.allocate_attribute("type","Proxy"));
- default_rule->append_node(action);
- }
- }
-}
-
-bool p_save_proxy_chains(std::list<config::p_proxy_chain> *list, config *cfg, const char *path)
-{
-}
-*/
\ No newline at end of file diff --git a/server/server/p_xml.h b/server/server/p_xml.h deleted file mode 100755 index 58e34d4..0000000 --- a/server/server/p_xml.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef XML_H
-#define XML_H
-
-/*
-bool p_load_proxy_list(std::list<config::p_proxy_entry> *list, config *cfg, const char* path = NULL);
-bool p_load_proxy_chains(std::list<config::p_proxy_chain> *list, config *cfg, const char *path = NULL);
-bool p_save_proxy_list(std::list<config::p_proxy_entry> *list, config *cfg, const char *path = NULL);
-bool p_sset_default_rule(config::p_proxy_entry *entry, config *cfg, const char *path = NULL);
-bool p_save_proxy_chains(std::list<config::p_proxy_chain> *list, config *cfg, const char *path = NULL);
- * */
-
-#endif
\ No newline at end of file |