Git Product home page Git Product logo

go-libp2p-net's Introduction

go-libp2p-net

Discourse posts

Network interfaces for go-libp2p

The libp2p Network package handles all of the peer-to-peer networking. It connects to other hosts, it encrypts communications, it muxes messages between the network's client services and target hosts. It has multiple subcomponents:

  • Conn - a connection to a single Peer
    • MultiConn - a set of connections to a single Peer
    • SecureConn - an encrypted (tls-like) connection
  • Swarm - holds connections to Peers, multiplexes from/to each MultiConn
  • Muxer - multiplexes between Services and Swarm. Handles Request/Reply.
    • Service - connects between an outside client service and Network.
    • Handler - the client service part that handles requests

It looks a bit like this:

[]

Install

go get libp2p/go-libp2p-net

Contribute

Feel free to join in. All welcome. Open an issue!

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to libp2p are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

Want to hack on IPFS?

License

MIT © 2016 Jeromy Johnson


The last gx published version of this module was: 3.0.30: QmY3ArotKMKaL7YGfbQfyDrib6RVraLqZYWXZvVgZktBxp

go-libp2p-net's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-libp2p-net's Issues

Conn and Stream should provide Contexts

It's often useful to have some idea of when a connection is lost. This is especially true when working with multiplexed connections where a given stream may become unusable because it's underlying connection has been closed.

I'm quite fond of the approach taken by https://github.com/lucas-clemente/quic-go. QUIC-go's Session and Stream interfaces export the Context() method. The returned context expires when the Session/Stream is no longer usable.

Does this seem feasible in libp2p?

`Conn.Stat().Extra` and `Stream.Stat().Extra` are nil. Cannot assign values.

It is currently impossible to assign values to the Extra map from within a net.Notifiee method. Indeed, in e.g. Notifiee.Connected(), conn.Stat().Extra is nil.

It would be nice to have an initialized map, here, as it allows library users to pass around contextual information. An alternative might be to extend #32 to support a WithContext() method similar to http.Request. This would allow users to bind contextual data to connections/streams via context.Context, which feels a bit more idiomatic.

Thoughts?

LICENSE file

Please add a LICENSE file so that this package will be vendor-able by third parties.

conn.RemotePeer() returning the wrong peer ID with a circuit relay

Imagine we just dialed a peer with the multiaddress of /ip4/127.0.0.1/tcp/5002/p2p/QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ/p2p-circuit/p2p/QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt

h.Network().Notify(&inet.NotifyBundle{
    ConnectedF: func(net inet.Network, conn inet.Conn) {
      // Must be handled in a goroutine as this callback cannot be blocking.
      go func() {

        s, err := h.NewStream(
          context.Background(),
          conn.RemotePeer(), // QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ
          handshakeProtocol,
        )
     ...
     ...
   }()
 })

conn.RemotePeer() returns the peer ID of the circuit/relay node (QmdPU7PfRyKehdrP5A3WqmjyD6bhVpU1mLGKppa2FjGDjZ), not the specific peer (QmVT6GYwjeeAF5TR485Yc58S3xRF5EFsZ5YAF4VcP3URHt). As a result, the stream is with the wrong peer.

I can't figure out where the implementation of the Conn interface is so I have no idea where to start investigating this further.

Additionally, it would be nice if conn.NewStream(procotol) worked. It would be intuitive to call this when I want to open/use a stream with the remote peer.

Additional events

For example:

  • DialAddr(peer, multiaddr)
  • Dial(peer)
  • Error(type, peer, multiaddr)

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.