This package has been deprecated and is no longer used by go-libp2p. Now that transports are responsible for securing and multiplexing connections, the bulk of the logic in this package has been moved to go-libp2p-transport-upgrader, and the rest into go-libp2p-swarm.
- go-libp2p-swarm -- some of the dial logic
A library providing 'Connection' objects for libp2p.
This package offers wrappers for go-libp2p-transport
raw types,
exposing go-libp2p-interface-conn
types.
It negotiates either plaintext or secio over the raw connection
using go-multistream
.
make deps
On the server side, a go-libp2p-transport
Listener is wrapped in a go-libp2p-interface-conn
Listener with WrapTransportListener
. Such iconn.Listener
has a peer identity: an ID and a secret key. These are only used when connections are encrypted, and a missing secret key forces plaintext connections.
On the client side, a Dialer
creates go-libp2p-interface-conn
connections using a set of go-libp2p-transport
Dialers. Like with Listener, a Dialer has an ID and private key identity to be used to negotiate encrypted connections. Dial also checks the peer identity if encryption is enabled by specifying a secret key in Dialer.
Encryption is forced on when go-libp2p-interface-conn.EncryptConnections
is true and the Dialer/Listener has a secret key, and forced off otherwise.
The protocol is fairly straightforward: upon opening a connection, go-multistream
is used to agree on plaintext ("/plaintext/1.0.0"
) or encrypted ("/secio/1.0.0"
). Plaintext will only be negotiated iff both peers have go-libp2p-interface-conn.EncryptConnections
set to false
or haven't constructed their Listeners/Dialers with secret keys.
If plaintext is selected, the connection is used as-is for the rest of its lifetime.
If encrypted is selected, go-libp2p-secio
is used to negotiate a transparent encrypted tunnel. The negotiation happens before the connection is made available to the library consumer.
PRs are welcome!
Small note: If editing the Readme, please conform to the standard-readme specification.
make deps
go test
MIT © Jeromy Johnson