aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2017-04-16 22:00:46 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2017-04-16 22:00:46 +0200
commit33f81a3a57a047326160f371f3269dfb47c59cba (patch)
treedc6e39bca104d7d440f19ae0d663b42afea2835f
parentd680f8d3848cbc3adf7d6b2c49e10abc4499cfca (diff)
downloadcmix-33f81a3a57a047326160f371f3269dfb47c59cba.tar.gz
cmix-33f81a3a57a047326160f371f3269dfb47c59cba.tar.bz2
cmix-33f81a3a57a047326160f371f3269dfb47c59cba.zip
Some cleanup and tweaked the statsd slightly.
-rw-r--r--libcmix-crypto/elgamal/gcrypt/gcrypt_elgamal.c4
-rw-r--r--node/node_node.cpp24
-rwxr-xr-xrun.sh7
-rw-r--r--statsd/main.cpp13
-rw-r--r--statsd/stats.cpp7
-rw-r--r--statsd/stats.hpp6
m---------wubwubcmake0
7 files changed, 24 insertions, 37 deletions
diff --git a/libcmix-crypto/elgamal/gcrypt/gcrypt_elgamal.c b/libcmix-crypto/elgamal/gcrypt/gcrypt_elgamal.c
index 8f8019a..57e6c41 100644
--- a/libcmix-crypto/elgamal/gcrypt/gcrypt_elgamal.c
+++ b/libcmix-crypto/elgamal/gcrypt/gcrypt_elgamal.c
@@ -19,7 +19,7 @@ static gcry_mpi_t q;
static gcry_mpi_t g;
static const unsigned int nr_bytes = 256;
static const unsigned int nr_bits = 256*8;
-static const unsigned int message_size = nr_bytes-1;
+static const unsigned int message_size = 255;
void check(gcry_error_t error) {
if (error) {
@@ -410,4 +410,4 @@ SharedKeyDeleter elgamal_delete_shared_key = &gcrypt_elgamal_delete_shared_key;
Encrypter elgamal_encrypt = &gcrypt_elgamal_encrypt;
Inverter elgamal_invert = &gcrypt_elgamal_invert;
UniformIntGetter elgamal_get_uniform_int = &gcrypt_elgamal_get_uniform_int;
-Deinitializer elgamal_deinitialize = &gcrypt_elgamal_deinitialize; \ No newline at end of file
+Deinitializer elgamal_deinitialize = &gcrypt_elgamal_deinitialize;
diff --git a/node/node_node.cpp b/node/node_node.cpp
index 14e3604..844fdc3 100644
--- a/node/node_node.cpp
+++ b/node/node_node.cpp
@@ -454,31 +454,9 @@ void Node::handle_node_realpost(cmix_proto::RealPost const& realpost) {
for(auto i = 0u; i < cmix_ctx.nr_participants; i++) {
- {
- for(int j = 0; j < 32; j++) {
- std::cout << std:: setw(4) << j;
- }
- std::cout << std::endl;
-
- for(int j = 0; j < 32; j++) {
- std::cout << std::setw(4) << (0xFF & (unsigned int) msgs[i][32+j]) ;
- }
- std::cout << std::endl;
- }
-
char* message;
element_to_message(&cmix_ctx, (unsigned char**) &message, msgs[i]);
- for(int i = 0; i < 31; i++) {
- std::cout << std:: setw(4) << i;
- }
- std::cout << std::endl;
-
- for(int i = 0; i < 31; i++) {
- std::cout << std::setw(4) << (0xFF & (unsigned int) message[i]) ;
- }
- std::cout << std::endl;
-
char* dest;
size_t dest_len;
@@ -582,4 +560,4 @@ void Node::handle_node_message(cmix_proto::CMixMessage message)
prev_node.async_receive([this](cmix_proto::CMixMessage message2) {
handle_node_message(message2);
});
-} \ No newline at end of file
+}
diff --git a/run.sh b/run.sh
index 5047602..72d83d8 100755
--- a/run.sh
+++ b/run.sh
@@ -1,7 +1,8 @@
#!/bin/bash
-build_dir=/home/dennis/projects/cmix/build-cmix-Desktop-Debug
+#build_dir=/home/dennis/projects/cmix/build-cmix-Desktop-Debug
#build_dir=/home/dbrentje/projects/cmix/build
+build_dir=/home/dennis/projects/cmix/build-Default
if [ $# == 0 ] ; then
tool=""
@@ -21,7 +22,7 @@ nr_clients=500
tmux new-session -s cmix -d
-tmux send-keys -t cmix:0 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool statsd/statsd" Enter
+#tmux send-keys -t cmix:0 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool statsd/statsd" Enter
tmux new-window -t cmix:1
tmux send-keys -t cmix:1 "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool node/node -f -m ${nr_clients} -n node2.local:9201 -s localhost:9199 -a node1 -c ../certs/cert1.pem -k ../certs/key1.pem -d ../certs/dh.pem --certdir ../certs/" Enter
@@ -38,7 +39,7 @@ do
tmux send-keys -t cmix:${i} "cd ${build_dir} && LSAN_OPTIONS=report_objects=1 $tool client/client --certdir ../certs -n node1.local:9200 node2.local:9201 node3.local:9202" Enter
done
-tmux select-window -t cmix:3
+tmux select-window -t cmix:4
tmux attach
tmux kill-session -t cmix
diff --git a/statsd/main.cpp b/statsd/main.cpp
index d20abc3..33ab0f8 100644
--- a/statsd/main.cpp
+++ b/statsd/main.cpp
@@ -7,7 +7,18 @@
#include <iostream>
+#include <csignal>
+
+boost::asio::io_service io_service{};
+
+void int_handler(int) {
+ io_service.stop();
+}
+
int main(int argc, char* argv[]) {
+
+ std::signal(SIGINT, int_handler);
+
namespace po = boost::program_options;
init_logging(boost::log::trivial::severity_level::trace, "statsd");
@@ -39,7 +50,7 @@ int main(int argc, char* argv[]) {
uint16_t port = vm["port"].as<uint16_t>();
ListenSettings lsettings{en4, if4, en6, if6, port, false, "", "", ""};
- Stats stats(lsettings);
+ Stats stats(io_service, lsettings);
stats.run();
diff --git a/statsd/stats.cpp b/statsd/stats.cpp
index e2a6a5d..a448449 100644
--- a/statsd/stats.cpp
+++ b/statsd/stats.cpp
@@ -6,9 +6,6 @@ void Stats::accept_connection(std::unique_ptr<boost::asio::ip::tcp::socket>&& so
auto it = connections.emplace(connections.end(), std::move(socket));
it->on_done([this, it](){
connections.erase(it);
- if(connections.empty()) {
- server.close();
- }
});
it->async_receive([it, this](cmix_proto::CMixMessage const& message) {
handle_message(it, message);
@@ -44,8 +41,8 @@ void Stats::handle_message(std::list<Receiver>::iterator it, cmix_proto::CMixMes
}
}
-Stats::Stats(ListenSettings lsettings)
-: io_service()
+Stats::Stats(boost::asio::io_service& io_service, ListenSettings lsettings)
+: io_service(io_service)
, server(io_service, lsettings, [this](std::unique_ptr<boost::asio::ip::tcp::socket>&& socket){accept_connection(std::move(socket));})
{}
diff --git a/statsd/stats.hpp b/statsd/stats.hpp
index b6e4bca..bcf85c5 100644
--- a/statsd/stats.hpp
+++ b/statsd/stats.hpp
@@ -10,7 +10,7 @@
#include <list>
class Stats {
- boost::asio::io_service io_service;
+ boost::asio::io_service& io_service;
Server server;
std::list<Receiver> connections;
@@ -27,8 +27,8 @@ class Stats {
void handle_message(std::list<Receiver>::iterator it, cmix_proto::CMixMessage message);
public:
- Stats(ListenSettings lsettings);
+ Stats(boost::asio::io_service& io_service, ListenSettings lsettings);
void run();
void output(std::string file);
-}; \ No newline at end of file
+};
diff --git a/wubwubcmake b/wubwubcmake
-Subproject dedc4ddbe0ba54677a5595b014cbf8480c6e653
+Subproject 056ae6f54cb420e2d033338ab011fd9b1cfe04e