summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-11-20 23:33:07 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2011-11-20 23:33:07 +0200
commit9f4097ebcdc5368a74e7590928e4cf964b3bc96c (patch)
tree4c3a311c4a02000e1d74233968e60f3f4ad624df /server
parent70af36496ce8102926c07ab02ae232e4df5b47e4 (diff)
md5 hashes in upload list (untested)
Diffstat (limited to 'server')
-rw-r--r--server/proxy_ui_server.workspace12
-rw-r--r--server/server/config.cpp15
-rw-r--r--server/server/headers.h1
3 files changed, 15 insertions, 13 deletions
diff --git a/server/proxy_ui_server.workspace b/server/proxy_ui_server.workspace
index fef20c5..6c4621d 100644
--- a/server/proxy_ui_server.workspace
+++ b/server/proxy_ui_server.workspace
@@ -10,16 +10,6 @@
</WorkspaceConfiguration>
</BuildMatrix>
<Environment>
- <![CDATA[
-
-
-
-
-
-
-
-
-
- ]]>
+ <![CDATA[]]>
</Environment>
</CodeLite_Workspace>
diff --git a/server/server/config.cpp b/server/server/config.cpp
index 60b7946..5fcdfc4 100644
--- a/server/server/config.cpp
+++ b/server/server/config.cpp
@@ -83,14 +83,25 @@ void config::load_upload_list(char *pth)
p1 = p2+l;
std::string::size_type lp1 = 0, lp2 = 0;
std::string source, destination, hash;
- byte *hash_buf = NULL;
lp1++;
lp2 = line.find('"', lp1);
source = line.substr(lp1, lp2-lp1);
lp1 = lp2+3;
lp2 = line.find('"', lp1);
destination = line.substr(lp1, lp2-lp1);
- //TODO calc hash
+ std::ifstream file;
+ MD5_CTX c = {0};
+ MD5_Init(&c);
+ file.open(source.c_str());
+ if(file.is_open())
+ {
+ char hash_buf[1024];
+ while(!file.eof())
+ MD5_Update(&c, hash_buf, file.readsome(hash_buf, 1024));
+ unsigned char result[MD5_DIGEST_LENGTH];
+ MD5_Final(result, &c);
+ hash = (char*)result;
+ }
upload_list.push_back(upload_entry(source, destination, hash));
p2 = cfg_str.find(';', p1);
}
diff --git a/server/server/headers.h b/server/server/headers.h
index 3d12023..5fe3726 100644
--- a/server/server/headers.h
+++ b/server/server/headers.h
@@ -20,6 +20,7 @@
#include <boost/thread/thread.hpp>
#include <boost/date_time.hpp>
#include <boost/filesystem.hpp>
+#include <openssl/md5.h>
#include "utilities.h"
#include "main.h"