Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use latest dht-rpc to avoid dns calls in 99% of cases #189

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Options include:
```js
{
// Optionally overwrite the default bootstrap servers, just need to be an array of any known dht node(s)
// Defaults to ['node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737']
// Defaults to ['88.99.3.86@node1.hyperdht.org:49737', '142.93.90.113@node2.hyperdht.org:49737', '138.68.147.8@node3.hyperdht.org:49737']
// Supports suggested-IP to avoid DNS calls: [suggested-IP@]<host>:<port>
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).
Expand Down
6 changes: 3 additions & 3 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const COMMANDS = exports.COMMANDS = {
}

exports.BOOTSTRAP_NODES = [
{ host: 'node1.hyperdht.org', port: 49737 },
{ host: 'node2.hyperdht.org', port: 49737 },
{ host: 'node3.hyperdht.org', port: 49737 }
'88.99.3.86@node1.hyperdht.org:49737',
'142.93.90.113@node2.hyperdht.org:49737',
'138.68.147.8@node3.hyperdht.org:49737'
]

exports.FIREWALL = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"compact-encoding": "^2.4.1",
"compact-encoding-net": "^1.0.1",
"debugging-stream": "^2.0.0",
"dht-rpc": "^6.11.3",
"dht-rpc": "^6.14.0",
"hypercore-crypto": "^3.3.0",
"hypercore-id-encoding": "^1.2.0",
"hypertrace": "^1.3.0",
Expand Down
24 changes: 24 additions & 0 deletions test/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,27 @@ test('connectionKeepAlive passed to server and connection', async function (t) {
await a.destroy()
await b.destroy()
})

test('bootstrap with suggested-IP', async function (t) {
const [boot] = await swarm(t, 1)
const bootstrap = ['127.0.0.1@invalid:' + boot.address().port]
const a = new DHT({ bootstrap, quickFirewall: false, ephemeral: false })
await a.ready()

t.alike(boot.toArray(), [{ host: '127.0.0.1', port: a.address().port }])

await a.destroy()
})

test('fail to bootstrap completely', async function (t) {
const [boot] = await swarm(t, 1)
const bootstrap = ['invalid:49737']
const a = new DHT({ bootstrap, quickFirewall: false, ephemeral: false })
await a.ready()

const empty = []
t.alike(a.toArray(), empty)
t.alike(boot.toArray(), empty)

await a.destroy()
})
Loading