From ff5a9c0106fb8d2f9ea4e723614968bc8d8588a4 Mon Sep 17 00:00:00 2001 From: Gaspard Kirira Date: Sat, 31 Jan 2026 13:50:22 +0300 Subject: [PATCH] chore: sync core, p2p and p2p_http modules + update config - Sync core module (configurable HTTP session timeout) - Sync p2p and p2p_http modules - Update config.json (server/session settings) - Remove obsolete config copy - Update README --- README.md | 39 ++++++++++++++++++++++++++++++++++----- config/config copy.json | 24 ------------------------ config/config.json | 20 +++++++++++++++++++- modules/core | 2 +- modules/p2p | 2 +- modules/p2p_http | 2 +- 6 files changed, 56 insertions(+), 33 deletions(-) delete mode 100644 config/config copy.json diff --git a/README.md b/README.md index 21660df..2359e1c 100644 --- a/README.md +++ b/README.md @@ -182,23 +182,52 @@ int main() ```cpp #include #include +#include +#include #include +using namespace vix; int main() { - vix::App app; + App app; + + vix::p2p::NodeConfig cfg; + cfg.node_id = "A"; + cfg.listen_port = 9001; + + auto node = vix::p2p::make_tcp_node(cfg); + vix::p2p::P2PRuntime runtime(node); + runtime.start(); - P2PHttpOptions opt; + vix::p2p_http::P2PHttpOptions opt; + opt.prefix = "/api/p2p"; + opt.enable_ping = true; + opt.enable_status = true; opt.enable_peers = true; + opt.enable_logs = true; + opt.enable_live_logs = true; + opt.stats_every_ms = 250; - install_p2p_http(app, opt); + vix::p2p_http::registerRoutes(app, runtime, opt); + + app.static_dir("./public"); + app.get("/", [](Request &, Response &res){ + res.file("./public/index.html"); + }); - app.listen(5178, [](const vix::utils::ServerReadyInfo& info) { - vix::console.info("UI API listening on", info.port); + app.get("/connect", [](Request &, Response &res){ + res.file("./public/connect.html"); + }); + + app.listen(5178, [](const vix::utils::ServerReadyInfo &info){ + console.info("UI API listening on", info.port); }); app.wait(); + runtime.stop(); } + + ``` --- diff --git a/config/config copy.json b/config/config copy.json deleted file mode 100644 index a938217..0000000 --- a/config/config copy.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "database": { - "default": { - "ENGINE": "mysql", - "NAME": "mydb", - "USER": "myuser", - "PASSWORD": "", - "HOST": "localhost", - "PORT": 3306 - } - }, - - "server": { - "port": 8080, - "request_timeout": 5000 - }, - - "websocket": { - "port": 9090, - "max_message_size": 65536, - "idle_timeout": 60, - "ping_interval": 30 - } -} diff --git a/config/config.json b/config/config.json index 9e5fa6f..0518df8 100644 --- a/config/config.json +++ b/config/config.json @@ -2,7 +2,8 @@ "server": { "port": 8080, "request_timeout": 2000, - "io_threads": 0 + "io_threads": 0, + "session_timeout_sec": 120 }, "logging": { "async": true, @@ -13,5 +14,22 @@ "mode": "basic", "max_target_len": 4096, "max_body_bytes": 1048576 + }, + "websocket": { + "port": 9090, + "max_message_size": 65536, + "idle_timeout": 60, + "ping_interval": 30, + "enable_deflate": true, + "auto_ping_pong": true + }, + "database": { + "default": { + "host": "localhost", + "port": 3306, + "name": "mydb", + "user": "myuser", + "password": "" + } } } diff --git a/modules/core b/modules/core index 0be4577..5abc4a1 160000 --- a/modules/core +++ b/modules/core @@ -1 +1 @@ -Subproject commit 0be4577129de06367d5c77d2c77ab902dddb3525 +Subproject commit 5abc4a106c5141112daed5b7ec1697cf3abc3ba1 diff --git a/modules/p2p b/modules/p2p index 87550dc..fc3ef1d 160000 --- a/modules/p2p +++ b/modules/p2p @@ -1 +1 @@ -Subproject commit 87550dc02331c8be95d7c5ceb216025232b94a67 +Subproject commit fc3ef1d450c06949e78543a7faa4aea1c591b337 diff --git a/modules/p2p_http b/modules/p2p_http index 0bf96b4..4aca936 160000 --- a/modules/p2p_http +++ b/modules/p2p_http @@ -1 +1 @@ -Subproject commit 0bf96b49880408d9834892b7129e019bbffce0f1 +Subproject commit 4aca936f4457b6f4083f166bc2bdcb5133cfcb36