From 857ac569274072b078d52dfd8018b9fe07c51773 Mon Sep 17 00:00:00 2001 From: supersuryaansh Date: Mon, 18 Nov 2024 20:50:37 +0530 Subject: [PATCH] Added option to add custom interval between punches --- README.md | 4 +++- index.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68858d8..d631f6b 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,9 @@ Options include: // Supports suggested-IP to avoid DNS calls: [suggested-IP@]: bootstrap: ['host:port'], keyPair, // set the default key pair to use for server.listen and connect - connectionKeepAlive // set a default keep-alive (in ms) on all opened sockets. Defaults to 5000. Set false to turn off (advanced usage). + connectionKeepAlive, // set a default keep-alive (in ms) on all opened sockets. Defaults to 5000. Set false to turn off (advanced usage). + randomPunchInterval: 20000 // set a default time for interval between punches (in ms). Defaults to 20000. + } ``` diff --git a/index.js b/index.js index 31a8698..a2d3923 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,7 @@ class HyperDHT extends DHT { this._validatedLocalAddresses = new Map() this._lastRandomPunch = 0 - this._randomPunchInterval = 20000 // min 20s between random punches... + this._randomPunchInterval = opts.randomPunchInterval || 20000 // min 20s between random punches... this._randomPunches = 0 this._randomPunchLimit = 1 // set to one for extra safety for now