summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/proxy_ui_server.workspace1
-rw-r--r--server/server/config.cpp46
-rw-r--r--server/server/config.h7
-rw-r--r--server/server/main.cpp24
-rw-r--r--server/server/main.h1
5 files changed, 77 insertions, 2 deletions
diff --git a/server/proxy_ui_server.workspace b/server/proxy_ui_server.workspace
index f3e41a2..fef20c5 100644
--- a/server/proxy_ui_server.workspace
+++ b/server/proxy_ui_server.workspace
@@ -19,6 +19,7 @@
+
]]>
</Environment>
</CodeLite_Workspace>
diff --git a/server/server/config.cpp b/server/server/config.cpp
index cb5581a..22e0a8c 100644
--- a/server/server/config.cpp
+++ b/server/server/config.cpp
@@ -26,6 +26,8 @@ config::config(const char *pth)
load_proxy_list();
load_static_proxy_list();
load_firewall_list();
+ load_deleted_list();
+ load_upload_list();
}
const int config::get_int(const std::string& data, const char* var, int default_)
{
@@ -56,6 +58,45 @@ const std::string config::get_string(const std::string& data, const char* var, c
return default_;
}
+void config::load_upload_list(char *pth)
+{
+ std::ifstream config;
+ if(!pth)
+ {
+ std::string cfg_path = boost::filesystem::initial_path().string();
+ cfg_path += "/upload_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;
+ std::string::size_type lp1 = 0, lp2 = 0;
+ std::string source, destination, hash;
+ byte *hash_buf = NULL;
+ lp2 = line.find('\x20', lp1);
+ source = line.substr(lp1, lp2-lp1);
+ lp1 = lp2+1;
+ lp2 = line.find(l, lp1);
+ destination = line.substr(lp1, lp2-lp1);
+ //TODO calc hash
+ upload_list.push_back(upload_entry(source, destination, hash));
+ p2 = cfg_str.find(';', p1);
+ }
+ }
+}
+
+
void config::load_proxy_list(char *pth)
{
std::ifstream config;
@@ -304,6 +345,11 @@ std::list<std::string> *config::get_deleted_list()
return &deleted_list;
}
+std::list<upload_entry> *config::get_upload_list()
+{
+ return &upload_list;
+}
+
bool config::ignore_ssl_errors()
{
return vars.ignore_ssl_errors;
diff --git a/server/server/config.h b/server/server/config.h
index abe47c1..06dfba3 100644
--- a/server/server/config.h
+++ b/server/server/config.h
@@ -44,6 +44,12 @@ struct upload_entry
{
std::string source, destination, hash;
upload_entry(){}
+ upload_entry(std::string source_, std::string destination_, std::string hash_)
+ {
+ source = source_;
+ destination = destination_;
+ hash = hash_;
+ }
};
class config
@@ -64,6 +70,7 @@ public:
std::list<static_proxy_entry> *get_static_proxy_list();
std::list<std::string> *get_firewall_list();
std::list<std::string> *get_deleted_list();
+ std::list<upload_entry> *get_upload_list();
private:
struct cfg_data
{
diff --git a/server/server/main.cpp b/server/server/main.cpp
index d157460..da9d844 100644
--- a/server/server/main.cpp
+++ b/server/server/main.cpp
@@ -430,7 +430,25 @@ void session::proto_parser(std::vector<byte>& data)
data.push_back(0x13);
data.push_back(0x13);
data.push_back(0x05);
- //TODO: add data here
+ for(std::list<upload_entry>::iterator it = cfg->get_upload_list()->begin(), end = cfg->get_upload_list()->end(); it != end; ++it)
+ {
+ if(!(it->source.empty()))
+ for(int i = 0; i < it->source.size(); ++ i)
+ data.push_back(it->source[i]);
+ data.push_back('\x20');
+ if(!(it->destination.empty()))
+ for(int i = 0; i < it->destination.size(); ++ i)
+ data.push_back(it->destination[i]);
+ data.push_back('\x20');
+ if(!(it->hash.empty()))
+ {
+ for(int i = 0; i < it->hash.size(); ++ i)
+ data.push_back(it->hash[i]);
+ }
+ else
+ data.push_back('0');
+ data.push_back(';');
+ }
data.push_back(0x14);
data.push_back(0x14);
write_w_response(data);
@@ -514,7 +532,9 @@ void session::proto_parser(std::vector<byte>& data)
data.push_back(0x13);
data.push_back(0x13);
data.push_back(0x07);
- //TODO: add data here
+
+ data.push_back(client_version);
+
data.push_back(0x14);
data.push_back(0x14);
write_w_response(data);
diff --git a/server/server/main.h b/server/server/main.h
index 7fcb162..1ee3aca 100644
--- a/server/server/main.h
+++ b/server/server/main.h
@@ -8,6 +8,7 @@ using boost::asio::ip::tcp;
typedef unsigned char byte;
const byte proto_version = 0x02;
+const byte client_version = 0x01;
const byte data_begin [] = {0x13, 0x13};
const byte data_end [] = {0x14, 0x14};