You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
I am using the new DHT implementation in the browser in a long-running SPA. I would like to use the DHT in 'server' mode in my particular application. However, the DHT is basically ignoring all peers because they are advertising a 'dns4' class address instead of an 'ip4' or 'ip6'. I am using the WebRTCStar protocol, which seems to work with 'ip4', but all of the examples use 'dns4'. In any case, obviously an DNS address could be either public or private...
Here is the diff that solved my problem:
``
diff --git a/node_modules/@libp2p/kad-dht/dist/src/utils.js b/node_modules/@libp2p/kad-dht/dist/src/utils.js
index a12c949..ae1b251 100644
--- a/node_modules/@libp2p/kad-dht/dist/src/utils.js
+++ b/node_modules/@libp2p/kad-dht/dist/src/utils.js
@@ -14,7 +14,7 @@ export function removePrivateAddresses(peer) {
...peer,
multiaddrs: peer.multiaddrs.filter(multiaddr => {
const [[type, addr]] = multiaddr.stringTuples();
if (type !== 4 && type !== 6) {
if (type !== 4 && type !== 6 && type !== 54) {
return false;
}
if (addr == null) {
I am using the new DHT implementation in the browser in a long-running SPA. I would like to use the DHT in 'server' mode in my particular application. However, the DHT is basically ignoring all peers because they are advertising a 'dns4' class address instead of an 'ip4' or 'ip6'. I am using the WebRTCStar protocol, which seems to work with 'ip4', but all of the examples use 'dns4'. In any case, obviously an DNS address could be either public or private...
Here is the diff that solved my problem:
``
diff --git a/node_modules/@libp2p/kad-dht/dist/src/utils.js b/node_modules/@libp2p/kad-dht/dist/src/utils.js
index a12c949..ae1b251 100644
--- a/node_modules/@libp2p/kad-dht/dist/src/utils.js
+++ b/node_modules/@libp2p/kad-dht/dist/src/utils.js
@@ -14,7 +14,7 @@ export function removePrivateAddresses(peer) {
...peer,
multiaddrs: peer.multiaddrs.filter(multiaddr => {
const [[type, addr]] = multiaddr.stringTuples();
@@ -28,8 +28,9 @@ export function removePublicAddresses(peer) {
return {
...peer,
multiaddrs: peer.multiaddrs.filter(multiaddr => {
const [[type, addr]] = multiaddr.stringTuples();
The text was updated successfully, but these errors were encountered: