diff options
-rw-r--r-- | server/proxy_ui_server.workspace | 2 | ||||
-rw-r--r-- | server/server/config.cpp | 33 | ||||
-rw-r--r-- | server/server/config.h | 12 | ||||
-rw-r--r-- | server/server/main.cpp | 12 |
4 files changed, 55 insertions, 4 deletions
diff --git a/server/proxy_ui_server.workspace b/server/proxy_ui_server.workspace index 428269e..f3e41a2 100644 --- a/server/proxy_ui_server.workspace +++ b/server/proxy_ui_server.workspace @@ -17,6 +17,8 @@ + + ]]> </Environment> </CodeLite_Workspace> diff --git a/server/server/config.cpp b/server/server/config.cpp index 1fa6ca2..cb5581a 100644 --- a/server/server/config.cpp +++ b/server/server/config.cpp @@ -222,6 +222,35 @@ void config::load_firewall_list(char* pth) } } +void config::load_deleted_list(char* pth) +{ + std::ifstream config; + if(!pth) + { + std::string cfg_path = boost::filesystem::initial_path().string(); + cfg_path += "/deleted_list.cfg"; + config.open(cfg_path.c_str(), 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, l = 1; + if(cfg_str.find("\r\n") != std::string::npos) + l = 2; + p2 = cfg_str.find(';'); + while(p2 != std::string::npos) + { + std::string line = cfg_str.substr(p1, p2-p1); + p1 = p2+l; + deleted_list.push_back(line); + p2 = cfg_str.find(';', p1); + } + } +} + const int config::ban_time() { return vars.ban_time; @@ -270,6 +299,10 @@ std::list<std::string> *config::get_firewall_list() { return &firewall_list; } +std::list<std::string> *config::get_deleted_list() +{ + return &deleted_list; +} bool config::ignore_ssl_errors() { diff --git a/server/server/config.h b/server/server/config.h index b5fedd0..abe47c1 100644 --- a/server/server/config.h +++ b/server/server/config.h @@ -40,6 +40,12 @@ struct static_proxy_entry } }; +struct upload_entry +{ + std::string source, destination, hash; + upload_entry(){} +}; + class config { public: @@ -57,6 +63,7 @@ public: std::list<proxy_entry> *get_proxy_list(); std::list<static_proxy_entry> *get_static_proxy_list(); std::list<std::string> *get_firewall_list(); + std::list<std::string> *get_deleted_list(); private: struct cfg_data { @@ -78,10 +85,13 @@ private: void load_proxy_list(char* pth = NULL); void load_static_proxy_list(char* pth = NULL); void load_firewall_list(char* pth = NULL); + void load_upload_list(char* pth = NULL); + void load_deleted_list(char* pth = NULL); cfg_data vars; std::list<proxy_entry> proxy_list; std::list<static_proxy_entry> static_proxy_list; - std::list<std::string> firewall_list; + std::list<std::string> firewall_list, deleted_list; + std::list<upload_entry> upload_list; }; #endif
\ No newline at end of file diff --git a/server/server/main.cpp b/server/server/main.cpp index b2ad08d..d157460 100644 --- a/server/server/main.cpp +++ b/server/server/main.cpp @@ -411,7 +411,7 @@ void session::proto_parser(std::vector<byte>& data) } } break; - case 0x05: //existing files request + case 0x05: //existing files request (pairs list "file hash\n") { if(canceled) { @@ -450,7 +450,7 @@ void session::proto_parser(std::vector<byte>& data) } } break; - case 0x06: //files to del request + case 0x06: //files to del request (list "file\n") { if(canceled) { @@ -469,7 +469,13 @@ void session::proto_parser(std::vector<byte>& data) data.push_back(0x13); data.push_back(0x13); data.push_back(0x06); - //TODO: add data here + for(std::list<std::string>::iterator it = cfg->get_deleted_list()->begin(), end = cfg->get_deleted_list()->end(); it != end; ++it) + { + if(!(it->empty())) + for(int i = 0; i < it->size(); ++ i) + data.push_back((*it)[i]); + data.push_back(';'); + } data.push_back(0x14); data.push_back(0x14); write_w_response(data); |