mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Added binary support for user sockets. (#90)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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<conf::ip_port_pair> &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
|
||||
|
||||
@@ -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<conf::ip_port_pair> &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<int, comm_session> &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<conf::ip_port_pair> &req_known_remotes, const uint64_t max_msg_size);
|
||||
void stop();
|
||||
void firewall_ban(std::string_view ip, const bool unban);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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::ip_port_pair>(), conf::cfg.pubmaxsize) == -1)
|
||||
conf::cfg.pubport, ".sock-user", comm::SESSION_TYPE::USER, true, true, metric_thresholds, std::set<conf::ip_port_pair>(), conf::cfg.pubmaxsize) == -1)
|
||||
return -1;
|
||||
|
||||
LOG_INFO << "Started listening for user connections on " << std::to_string(conf::cfg.pubport);
|
||||
|
||||
Binary file not shown.
@@ -52,7 +52,7 @@ do
|
||||
appbillargs: '', \
|
||||
peerport: ${peerport}, \
|
||||
pubport: ${pubport}, \
|
||||
roundtime: 2000, \
|
||||
roundtime: 1000, \
|
||||
loglevel: 'debug', \
|
||||
loggers:['console', 'file'] \
|
||||
}, null, 2)" > hp.cfg
|
||||
|
||||
Reference in New Issue
Block a user