GithubHelp home page GithubHelp logo

Comments (5)

tullrich avatar tullrich commented on May 29, 2024 1

It appears this is an old issue, but I am still getting this when using the js-libp2p-mdns discovery module. It seems peers advertise the loopback address, which causes any listening peers to connect to themselves (while believing that they have successfully connected to the remote peer).

I am not seeing the js-libp2p-secio handshake reject this, in fact, they connection establishes an encrypted channel and mux on both ends and raises two 'peer:connect' events to my application. Is there a workaround for this that would prevent any dials on addresses that are obviously myself?

from js-libp2p.

tullrich avatar tullrich commented on May 29, 2024 1

Sure @dryajov, thank you for your quick response! I have pushed a small demo of this bug here.

This demo setups a simple libp2p bundle with TCP transport, mDNS discovery, and SECIO. It attempts to dial any discovered peers. When run from two hosts on the same local network I get the following output:

This Peer ID:  QmbQvNDBqvyDEP3LUmCNJYv8bLyxA2BP8bSYYRGVKr2Avv
Listening on addresses: 
 [ '/ip4/127.0.0.1/tcp/4043/ipfs/QmbQvNDBqvyDEP3LUmCNJYv8bLyxA2BP8bSYYRGVKr2Avv',
  '/ip4/10.20.0.123/tcp/4043/ipfs/QmbQvNDBqvyDEP3LUmCNJYv8bLyxA2BP8bSYYRGVKr2Avv' ]
Discovered: QmXQhdGGFJbGcQmUR4o4j4meVNR97u1GWaJt1PpfraVz1t
Connection established to: QmXQhdGGFJbGcQmUR4o4j4meVNR97u1GWaJt1PpfraVz1t
Connection established to: QmbQvNDBqvyDEP3LUmCNJYv8bLyxA2BP8bSYYRGVKr2Avv

The two 'peer:connect' events printed actually come from both halves of the same connection (since we have connected to our self) and the remote peer is not involved at all beyond the discovery broadcast. This can be verified with the full debug log found here. You can see that the advertised addresses from the remote peer contain a loopback address that we successfully connect to during dialMany().

Note that this will not occur if you attempt to connect two nodes from different ports on the same machine since the advertised loopback address will correctly reach the remote peer.

from js-libp2p.

dryajov avatar dryajov commented on May 29, 2024

@tullrich that certainly sounds like a bug, could you please provide a snippet that reproduces it?

from js-libp2p.

dryajov avatar dryajov commented on May 29, 2024

@tullrich thanks! I'll check it out shortly.

from js-libp2p.

p-shahi avatar p-shahi commented on May 29, 2024

The prescribed behavior by this issue isn't in accordance with the identify spec: https://github.com/libp2p/specs/tree/master/identify#identifypush

Closing this for now

from js-libp2p.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.