Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Public/Private IP address Screening Seems to be Too Strict on Protocols #407

Closed
justin0mcateer opened this issue Dec 5, 2022 · 1 comment

Comments

@justin0mcateer
Copy link

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) {
    

@@ -28,8 +28,9 @@ export function removePublicAddresses(peer) {
return {
...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) {
    

<em>This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).</em>
@justin0mcateer
Copy link
Author

Duplicate of #377

@justin0mcateer justin0mcateer closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant