Categorygithub.com/libp2p/go-libp2p-conn
modulepackage
0.0.0-20180608185440-fd8ad2883246
Repository: https://github.com/libp2p/go-libp2p-conn.git
Documentation: pkg.go.dev

# README

[[ DEPRECATED ]] go-libp2p-conn

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.

Coverage Status Travis CI

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.

Table of Contents

Install

make deps

Usage

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.

Protocol overview

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.

Contribute

PRs are welcome!

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

Tests

make deps
go test

License

MIT © Jeromy Johnson

# Functions

MultiaddrNetMatch returns the first Multiaddr found to match network.
MultiaddrProtocolsMatch returns whether two multiaddrs match in protocol stacks.
NewDialer creates a new Dialer object.
ReleaseBuffer puts the given byte array back into the appropriate global buffer pool based on its capacity.
WrapTransportListener wraps a raw transport.Listener in an iconn.Listener.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author

# Variables

AcceptTimeout is the maximum duration an Accept is allowed to take.
DialTimeout is the maximum duration a Dial is allowed to take.

# Structs

Dialer is an object with a peer identity that can open connections.

# Interfaces

No description provided by the author

# Type aliases

ConnWrapper is any function that wraps a raw multiaddr connection.