diff --git a/README.md b/README.md index fa2e62e4..033fe6a8 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ A C++ version of hotpocket designed for production envrionments, original protot ## Libraries * Crypto - Libsodium https://github.com/jedisct1/libsodium -* Websockets - [Websocketd](https://github.com/joewalnes/websocketd) | [Websocat](https://github.com/vi/websocat) | [netcat (OpenBSD)](https://man.openbsd.org/nc.1) +* Websockets - Server: [Websocketd (forked)](https://github.com/codetsunami/websocketd) | Client: [Websocat](https://github.com/vi/websocat) | Pipe: [netcat (OpenBSD)](https://man.openbsd.org/nc.1) * RapidJSON - http://rapidjson.org -* P2P Protocol - https://google.github.io/flatbuffers/ +* P2P Protocol - https://google.github.io/flatbuffers * Fuse filesystem - https://github.com/libfuse/libfuse -* Boost - https://www.boost.org/ +* Boost - https://www.boost.org ## Steps to setup Hot Pocket (For Ubuntu/Debian) diff --git a/src/comm/comm_server.cpp b/src/comm/comm_server.cpp index d527ed50..11b502cf 100644 --- a/src/comm/comm_server.cpp +++ b/src/comm/comm_server.cpp @@ -13,7 +13,7 @@ namespace comm { int comm_server::start( - const uint16_t port, const char *domain_socket_name, const SESSION_TYPE session_type, const bool is_binary, + const uint16_t port, const char *domain_socket_name, const SESSION_TYPE session_type, const bool is_binary, const bool use_size_header, const uint64_t (&metric_thresholds)[4], const std::set &req_known_remotes, const uint64_t max_msg_size) { int accept_fd = open_domain_socket(domain_socket_name); @@ -22,7 +22,7 @@ int comm_server::start( watchdog_thread = std::thread( &comm_server::connection_watchdog, this, accept_fd, session_type, is_binary, std::ref(metric_thresholds), req_known_remotes, max_msg_size); - return start_websocketd_process(port, domain_socket_name, is_binary); + return start_websocketd_process(port, domain_socket_name, is_binary, use_size_header); } return -1; @@ -253,7 +253,7 @@ void comm_server::maintain_known_connections( } } -int comm_server::start_websocketd_process(const uint16_t port, const char *domain_socket_name, const bool is_binary) +int comm_server::start_websocketd_process(const uint16_t port, const char *domain_socket_name, const bool is_binary, const bool use_size_header) { // setup pipe for firewall int firewall_pipe[2]; // parent to child pipe @@ -307,7 +307,7 @@ int comm_server::start_websocketd_process(const uint16_t port, const char *domai (char *)"--sslkey", conf::ctx.tls_key_file.data(), (char *)(is_binary ? "--binary=true" : "--binary=false"), - (char *)"--sizeheader=false", + (char *)(use_size_header? "--sizeheader=true" : "--sizeheader=false"), (char *)"--loglevel=error", (char *)"nc", // netcat (OpenBSD) is used for domain socket redirection. (char *)"-U", // Use UNIX domain socket diff --git a/src/comm/comm_server.hpp b/src/comm/comm_server.hpp index 03d13901..53500d82 100644 --- a/src/comm/comm_server.hpp +++ b/src/comm/comm_server.hpp @@ -21,7 +21,7 @@ class comm_server const int accept_fd, const SESSION_TYPE session_type, const bool is_binary, const uint64_t (&metric_thresholds)[4], const std::set &eq_known_remotes, const uint64_t max_msg_size); - int start_websocketd_process(const uint16_t port, const char *domain_socket_name, const bool is_binary); + int start_websocketd_process(const uint16_t port, const char *domain_socket_name, const bool is_binary, const bool use_size_header); int poll_fds(pollfd *pollfds, const int accept_fd, const std::unordered_map &sessions); @@ -39,7 +39,7 @@ class comm_server public: // Start accepting incoming connections int start( - const uint16_t port, const char *domain_socket_name, const SESSION_TYPE session_type, const bool is_binary, + const uint16_t port, const char *domain_socket_name, const SESSION_TYPE session_type, const bool is_binary, const bool use_size_header, const uint64_t (&metric_thresholds)[4], const std::set &req_known_remotes, const uint64_t max_msg_size); void stop(); void firewall_ban(std::string_view ip, const bool unban); diff --git a/src/p2p/p2p.cpp b/src/p2p/p2p.cpp index 904f55b2..66e8ed1f 100644 --- a/src/p2p/p2p.cpp +++ b/src/p2p/p2p.cpp @@ -36,7 +36,7 @@ int start_peer_connections() { const uint64_t metric_thresholds[] = {conf::cfg.peermaxcpm, conf::cfg.peermaxdupmpm, conf::cfg.peermaxbadsigpm, conf::cfg.peermaxbadmpm}; if (ctx.listener.start( - conf::cfg.peerport, ".sock-peer", comm::SESSION_TYPE::PEER, true, metric_thresholds, conf::cfg.peers, conf::cfg.peermaxsize) == -1) + conf::cfg.peerport, ".sock-peer", comm::SESSION_TYPE::PEER, true, false, metric_thresholds, conf::cfg.peers, conf::cfg.peermaxsize) == -1) return -1; LOG_INFO << "Started listening for peer connections on " << std::to_string(conf::cfg.peerport); diff --git a/src/usr/usr.cpp b/src/usr/usr.cpp index 9ae55c78..feaab35e 100644 --- a/src/usr/usr.cpp +++ b/src/usr/usr.cpp @@ -43,7 +43,7 @@ int start_listening() { const uint64_t metric_thresholds[] = {conf::cfg.pubmaxcpm, 0, 0, conf::cfg.pubmaxbadmpm}; if (ctx.listener.start( - conf::cfg.pubport, ".sock-user", comm::SESSION_TYPE::USER, false, metric_thresholds, std::set(), conf::cfg.pubmaxsize) == -1) + conf::cfg.pubport, ".sock-user", comm::SESSION_TYPE::USER, true, true, metric_thresholds, std::set(), conf::cfg.pubmaxsize) == -1) return -1; LOG_INFO << "Started listening for user connections on " << std::to_string(conf::cfg.pubport); diff --git a/test/bin/websocketd b/test/bin/websocketd index 81099617..b592e5d3 100755 Binary files a/test/bin/websocketd and b/test/bin/websocketd differ diff --git a/test/local-cluster/cluster-create.sh b/test/local-cluster/cluster-create.sh index d51e130d..4550a841 100755 --- a/test/local-cluster/cluster-create.sh +++ b/test/local-cluster/cluster-create.sh @@ -52,7 +52,7 @@ do appbillargs: '', \ peerport: ${peerport}, \ pubport: ${pubport}, \ - roundtime: 2000, \ + roundtime: 1000, \ loglevel: 'debug', \ loggers:['console', 'file'] \ }, null, 2)" > hp.cfg