Skip to content

Commit

Permalink
Merge pull request #15 from HDegroote/set-keep-alive
Browse files Browse the repository at this point in the history
Always set keetAlive
  • Loading branch information
prdn authored Apr 3, 2024
2 parents 531873a + 0f2b3a8 commit 16e6e5c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^6.14.0",
"minimist": "^1.2.5"
},
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion pub.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (!+argv.l) {
}

const conf = {}
conf.keepAlive = 5000

if (argv.seed) {
conf.seed = argv.seed
Expand Down Expand Up @@ -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 }
Expand Down
7 changes: 6 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if (argv.u && argv.l) {
}

const conf = {}
conf.keepAlive = 5000

if (argv.seed) {
conf.seed = argv.seed
Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit 16e6e5c

Please sign in to comment.