Code Monkey home page Code Monkey logo

Comments (3)

twittner avatar twittner commented on August 11, 2024 1

Yes, please file an issue in rust-libp2p. The connection upgrade there is always using Mode::Server for inbound and Mode::Client for outbound upgrades. libp2p-yamux needs to provide a way to override this. Ideally the transport builder also allows access to the connection info.

from rust-yamux.

twittner avatar twittner commented on August 11, 2024

Yes, this is expected behaviour. Yamux splits the stream ID space into two non-overlapping sets. The client set consists of odd IDs and the server set of even IDs. See https://github.com/hashicorp/yamux/blob/master/spec.md#streamid-field for details.

A tells B to start connecting to the public address of C. At the same time, A answers to C with the publicly visible IP of B. Both nodes create a socket and then bind it to the same address used to contact node A. It then use this socket to connect. B and C start trying to connect to each other, creating a hole in the NAT.

Even when connections are established by a simultaneous connect, one still needs to make one endpoint the server and the other the client. In general this could be based on the ordering of IP addresses, e.g. the endpoint with the smaller IP address assumes the client role and the other one the server. This is purely needed for the ID space split mentioned above and does not have other implications.

from rust-yamux.

BlackYoup avatar BlackYoup commented on August 11, 2024

Thanks for your response.

The client set consists of odd IDs and the server set of even IDs

Yes, that's what I understood of the current code.

Even when connections are established by a simultaneous connect, one still needs to make one endpoint the server and the other the client.

I implemented that logic in my PoC and indeed it works fine now. But in a libp2p project, I don't think I can do that. Maybe I should open an issue there with my use case?

from rust-yamux.

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.