Skip to content

Commit 5ae9064

Browse files
committed
feat(brave): delegated peers and content routing
This enables delegated routers in embedded js-ipfs running in Brave. Coupled with preload, this gives us basic file sharing functionality back, until we have real p2p transport, native DHT etc.
1 parent 14b547d commit 5ae9064

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

add-on/src/lib/options.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exports.optionDefaults = Object.freeze({
2424
ipfsApiUrl: buildIpfsApiUrl(),
2525
ipfsApiPollMs: 3000,
2626
ipfsProxy: true, // window.ipfs
27-
logNamespaces: 'jsipfs*,ipfs*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
27+
logNamespaces: 'jsipfs*,ipfs*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*'
2828
})
2929

3030
function buildCustomGatewayUrl () {
@@ -62,15 +62,21 @@ function buildDefaultIpfsNodeConfig () {
6262
// Until we have MulticastDNS+DNS, peer discovery is done over ws-star
6363
config.config.Addresses.Swarm = ['/dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star']
6464
// Until DHT and p2p transport are ready, delegate + preload
65+
// Note: we use .preload.ipfs.io and .delegate.ipfs.io as means of http sharding (12 instead of 6 concurrent requests)
6566
const delegates = [
66-
'/dns4/node0.preload.ipfs.io/tcp/443/https',
67-
'/dns4/node1.preload.ipfs.io/tcp/443/https'
67+
'/dns4/node1.delegate.ipfs.io/tcp/443/https',
68+
'/dns4/node0.delegate.ipfs.io/tcp/443/https'
6869
]
6970
// Delegated Content and Peer Routing: https://github.com/ipfs/js-ipfs/pull/2195
70-
// TODO: delegated routing blocked by https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/12
71-
// config.config.Addresses.Delegates = delegates
72-
// TODO: are preloads needed? should Brave have own nodes?
73-
config.preload = { enabled: true, addresses: delegates }
71+
config.config.Addresses.Delegates = delegates
72+
// TODO: when we have p2p transport, are preloads still needed? should Brave have own nodes?
73+
config.preload = {
74+
enabled: true,
75+
addresses: [
76+
'/dns4/node1.preload.ipfs.io/tcp/443/https',
77+
'/dns4/node0.preload.ipfs.io/tcp/443/https'
78+
]
79+
}
7480
/*
7581
(Sidenote on why we need API for Web UI)
7682
Gateway can run without API port,

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
"private": true,
6767
"preferGlobal": false,
6868
"resolutions": {
69+
"libp2p-delegated-content-routing": "0.3.1",
70+
"libp2p-delegated-peer-routing": "0.3.1",
6971
"@hapi/hapi": "https://github.com/lidel/hapi/tarball/ccbf84ba5edc9b24564fdd166e3ee6d81c4c02d8/hapi.tar.gz",
7072
"pino": "5.12.3",
7173
"hapi-pino": "https://github.com/pinojs/hapi-pino/tarball/3767ed6b67601831e176e084ed82ba4ed9f726e6/hapi-pino.tar.gz",

yarn.lock

+17-17
Original file line numberDiff line numberDiff line change
@@ -6798,7 +6798,7 @@ [email protected]:
67986798
resolved "https://registry.yarnpkg.com/ipfs-css/-/ipfs-css-0.12.0.tgz#becf48dbdfb1c913006ff0c6dc6c56752a2cb6b3"
67996799
integrity sha512-bU72aEG1LR1MVUnHIXsCxdZqJwKpQrh0Wod2aI1o940hVxobZqHEVw5PISdhVdtK42IaHhtq25wAl0zZlUwyiA==
68006800

6801-
[email protected], ipfs-http-client@^33.0.1, ipfs-http-client@^33.0.2, ipfs-http-client@^33.1.0:
6801+
[email protected], ipfs-http-client@^33.1.0:
68026802
version "33.1.0"
68036803
resolved "https://registry.yarnpkg.com/ipfs-http-client/-/ipfs-http-client-33.1.0.tgz#4d3beceba27fcef26cf1940375a5f8c9d609f0dd"
68046804
integrity sha512-hkS8nXay3DGKb/KXU1RDvTyxnvkAdhS5enlXxNXaS7yKvADlf5SEuQGYjW+VknkPPQ4FNbY3JttQ3YW+LTuoRA==
@@ -8550,25 +8550,25 @@ libp2p-crypto@~0.16.0, libp2p-crypto@~0.16.1:
85508550
tweetnacl "^1.0.0"
85518551
ursa-optional "~0.9.10"
85528552

8553-
libp2p-delegated-content-routing@^0.2.3:
8554-
version "0.2.3"
8555-
resolved "https://registry.yarnpkg.com/libp2p-delegated-content-routing/-/libp2p-delegated-content-routing-0.2.3.tgz#de3e923e70cbcfbbc2de679a84ad1c1c342a8129"
8556-
integrity sha512-WbHunAEJj5HzhbHKEep9myfoGa7/g4rWytyHLuC3syxbVpc9Tv4oQK0dD8G09YofGpIr/I4yUPaJY1GM7skGQQ==
8553+
libp2p-delegated-content-routing@0.3.1, libp2p-delegated-content-routing@^0.2.3:
8554+
version "0.3.1"
8555+
resolved "https://registry.yarnpkg.com/libp2p-delegated-content-routing/-/libp2p-delegated-content-routing-0.3.1.tgz#45e1711074a68d457c9b4bd92682ad06fb8857c8"
8556+
integrity sha512-GgEj1FHzNFH6nL0fQ5sFZWcskfWkwVLL+GtY5wZbe9izXftyg5QDVdoKSlYWQUrEjaaAJE+T4KjvtK83T/C7Yg==
85578557
dependencies:
8558-
async "^2.6.2"
8559-
ipfs-http-client "^33.0.2"
8558+
debug "^4.1.1"
8559+
ipfs-http-client "^33.1.0"
85608560
multiaddr "^6.1.0"
8561-
peer-id "^0.12.2"
8562-
peer-info "^0.15.1"
8561+
p-queue "^6.1.0"
85638562

8564-
libp2p-delegated-peer-routing@^0.2.3:
8565-
version "0.2.3"
8566-
resolved "https://registry.yarnpkg.com/libp2p-delegated-peer-routing/-/libp2p-delegated-peer-routing-0.2.3.tgz#b2c27bee2bd6a9f0147fc2ec12b5e1c9c6c982eb"
8567-
integrity sha512-yr5NRgAnVmsvhIC5COyEda+ZdD42JVfBeShsHj7FaRdYay4kdEpUXqLXiC7bC6PMbYSh2d/TheO3ITTj4Kp1Fw==
8563+
libp2p-delegated-peer-routing@0.3.1, libp2p-delegated-peer-routing@^0.2.3:
8564+
version "0.3.1"
8565+
resolved "https://registry.yarnpkg.com/libp2p-delegated-peer-routing/-/libp2p-delegated-peer-routing-0.3.1.tgz#331d129559b2b257cef5e13260d7ac50d4731768"
8566+
integrity sha512-WAN2rBsuiS1xqrAaZthKX9vVtXar0nH7ACAWoTNsk2BaAhhds0Shri48NB5jN//kxLo+vC7+WVn4Rgdg3Dp2sA==
85688567
dependencies:
8569-
ipfs-http-client "^33.0.1"
8570-
peer-id "^0.12.2"
8571-
peer-info "^0.15.1"
8568+
debug "^4.1.1"
8569+
ipfs-http-client "^33.1.0"
8570+
p-queue "^6.1.0"
8571+
peer-id "~0.12.2"
85728572

85738573
libp2p-floodsub@^0.16.1:
85748574
version "0.16.1"
@@ -10737,7 +10737,7 @@ p-map@^2.0.0:
1073710737
resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175"
1073810738
integrity sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==
1073910739

10740-
10740+
[email protected], p-queue@^6.1.0:
1074110741
version "6.1.0"
1074210742
resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-6.1.0.tgz#3f546275073b41e4af460e41459524b15c2753f3"
1074310743
integrity sha512-907vNz/cY+JEsqGglo7o/Ia9E/wisahJGOp9HPfbAyCVGERQVmFGA4IyknxY1v+QRBiMKedL3ToOBXNEy9MKQA==

0 commit comments

Comments
 (0)