conn

package module
v0.0.0-...-c7cda99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2018 License: MIT Imports: 10 Imported by: 6

README

[DEPRECATED] go-libp2p-interface-conn

This package has been deprecated and is no loner used by go-libp2p. Libp2p used to build up connections as follows:

  1. go "net" conn
  2. multiaddr conn -- net conn with multiaddrs
  3. go-libp2p-transport conn -- multiaddr conns with associated transports
  4. this package -- secured, multiplexed connections
  5. go-libp2p-net conn -- connections associated with a Network (e.g., go-libp2p-swarm).

However, go-libp2p-transport connections are now fully secured and multiplexed so the interfaces in this package have been subsumed by those in go-libp2p-transport.

Interfaces to implement to create a connection object for use in libp2p.

Table of Contents

Install

make install

Contribute

PRs are welcome!

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

License

MIT © Jeromy Johnson

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EncryptConnections = true

EncryptConnections is a global parameter because it should either be enabled or _completely disabled_. I.e. a node should only be able to talk to proper (encrypted) networks if it is encrypting all its transports. Running a node with disabled transport encryption is useful to debug the protocols, achieve implementation interop, or for private networks which -- for whatever reason -- _must_ run unencrypted.

Functions

func ID

func ID(c Conn) string

ID returns the ID of a given Conn.

func String

func String(c Conn, typ string) string

String returns the user-friendly String representation of a conn

Types

type Conn

type Conn interface {
	PeerConn

	// ID is an identifier unique to this connection.
	ID() string

	// can't just say "net.Conn" cause we have duplicate methods.
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	Transport() tpt.Transport

	io.Reader
	io.Writer
}

Conn is a generic message-based Peer-to-Peer connection.

type Listener

type Listener interface {

	// Accept waits for and returns the next connection to the listener.
	Accept() (tpt.Conn, error)

	// Addr is the local address
	Addr() net.Addr

	// Multiaddr is the local multiaddr address
	Multiaddr() ma.Multiaddr

	// LocalPeer is the identity of the local Peer.
	LocalPeer() peer.ID

	SetAddrFilters(*filter.Filters)

	// Close closes the listener.
	// Any blocked Accept operations will be unblocked and return errors.
	Close() error
}

Listener is an object that can accept connections. It matches net.Listener

type PeerConn

type PeerConn interface {
	io.Closer

	// LocalPeer (this side) ID, PrivateKey, and Address
	LocalPeer() peer.ID
	LocalPrivateKey() ic.PrivKey
	LocalMultiaddr() ma.Multiaddr

	// RemotePeer ID, PublicKey, and Address
	RemotePeer() peer.ID
	RemotePublicKey() ic.PubKey
	RemoteMultiaddr() ma.Multiaddr
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL