From 0e8c48ed039baa19e585cf784f93e1a812dd7e44 Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:00:00 +0200 Subject: [PATCH 1/4] Set keepAlive for client and server (WIP: using hyperdht branch) --- client.js | 5 ++--- package.json | 2 +- server.js | 7 ++++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client.js b/client.js index cad54fa..bad6c36 100644 --- a/client.js +++ b/client.js @@ -84,14 +84,13 @@ const stats = {} const dht = new HyperDHT({ bootstrap, - keyPair + keyPair, + connectionKeepAlive: conf.keepAlive }) const proxy = net.createServer({ allowHalfOpen: true }, c => { return connPiper(c, () => { const stream = dht.connect(Buffer.from(peer, 'hex'), { reusableSocket: true }) - stream.setKeepAlive(conf.keepAlive) - return stream }, { compress: conf.compress }, stats) }) diff --git a/package.json b/package.json index 865eea2..9018344 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@hyper-cmd/lib-utils": "https://github.com/holepunchto/hyper-cmd-lib-utils#v0.0.2", "b4a": "^1.6.4", "graceful-goodbye": "^1.3.0", - "hyperdht": "^6.11.0", + "hyperdht": "holepunchto/hyperdht#keep-alive-opt", "minimist": "^1.2.5" }, "bin": { diff --git a/server.js b/server.js index fe6914b..1337df2 100644 --- a/server.js +++ b/server.js @@ -27,6 +27,7 @@ if (argv.u && argv.l) { } const conf = {} +conf.keepAlive = 5000 if (argv.seed) { conf.seed = argv.seed @@ -69,7 +70,11 @@ const debug = argv.debug const seed = Buffer.from(conf.seed, 'hex') -const dht = new HyperDHT({ bootstrap }) +const dht = new HyperDHT({ + bootstrap, + connectionKeepAlive: conf.keepAlive +}) + const keyPair = HyperDHT.keyPair(seed) const stats = {} From 2e0c79e656cce5d03408521183ad2bcbb43215e3 Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:14:33 +0200 Subject: [PATCH 2/4] Use hyperdht ^6.14.0 (with connectionKeepAlive opt) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9018344..d3d10b3 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@hyper-cmd/lib-utils": "https://github.com/holepunchto/hyper-cmd-lib-utils#v0.0.2", "b4a": "^1.6.4", "graceful-goodbye": "^1.3.0", - "hyperdht": "holepunchto/hyperdht#keep-alive-opt", + "hyperdht": "^6.14.0", "minimist": "^1.2.5" }, "bin": { From 0f2b3a829928834caa5126fcd2b7c043b2835573 Mon Sep 17 00:00:00 2001 From: HDegroote <75906619+HDegroote@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:17:19 +0200 Subject: [PATCH 3/4] Add keepAlive to pub server --- pub.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pub.js b/pub.js index 2939bf0..90508af 100644 --- a/pub.js +++ b/pub.js @@ -21,6 +21,7 @@ if (!+argv.l) { } const conf = {} +conf.keepAlive = 5000 if (argv.seed) { conf.seed = argv.seed @@ -51,7 +52,7 @@ const debug = argv.debug const seed = Buffer.from(conf.seed, 'hex') -const dht = new HyperDHT() +const dht = new HyperDHT({ connectionKeepAlive: conf.keepAlive }) const keyPair = HyperDHT.keyPair(seed) const stats = { cid: 0 } From ab9d258baa5d30c582b80acd74431dc64e58f0a0 Mon Sep 17 00:00:00 2001 From: prdn Date: Wed, 3 Apr 2024 10:26:08 +0000 Subject: [PATCH 4/4] mc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3d10b3..4c2e23c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hypertele", - "version": "1.1.2", + "version": "1.1.3", "description": "TCP proxy over Hyperswarm!", "main": "index.js", "dependencies": {