go-libp2p-circuit: github.com/libp2p/go-libp2p-circuit Index | Files | Directories

package relay

import "github.com/libp2p/go-libp2p-circuit"

Index

Package Files

conn.go dial.go listen.go relay.go transport.go util.go

Constants

const P_CIRCUIT = ma.P_CIRCUIT

Deprecated: use ma.P_CIRCUIT

const ProtoID = "/libp2p/circuit/relay/0.1.0"

Variables

var (
    RelayAcceptTimeout   = 10 * time.Second
    HopConnectTimeout    = 30 * time.Second
    StopHandshakeTimeout = 1 * time.Minute

    HopStreamBufferSize = 4096
    HopStreamLimit      = 1 << 19 // 512K hops for 1M goroutines

)
var (
    // OptActive configures the relay transport to actively establish
    // outbound connections on behalf of clients. You probably don't want to
    // enable this unless you know what you're doing.
    OptActive = RelayOpt(0)
    // OptHop configures the relay transport to accept requests to relay
    // traffic on behalf of third-parties. Unless OptActive is specified,
    // this will only relay traffic between peers already connected to this
    // node.
    OptHop = RelayOpt(1)
    // OptDiscovery is a no-op. It was introduced as a way to probe new
    // peers to see if they were willing to act as a relays. However, in
    // practice, it's useless. While it does test to see if these peers are
    // relays, it doesn't (and can't), check to see if these peers are
    // _active_ relays (i.e., will actively dial the target peer).
    //
    // This option may be re-enabled in the future but for now you shouldn't
    // use it.
    OptDiscovery = RelayOpt(2)
)
var HopTagWeight = 5

HopTagWeight is the connection manager weight for connections carrying relay hop streams

var Protocol = ma.ProtocolWithCode(P_CIRCUIT)

Deprecated: use ma.ProtocolWithCode(P_CIRCUIT)

func AddRelayTransport Uses

func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) error

AddRelayTransport constructs a relay and adds it as a transport to the host network.

func CanHop Uses

func CanHop(ctx context.Context, host host.Host, id peer.ID) (bool, error)

Queries a peer for support of hop relay

type Conn Uses

type Conn struct {
    // contains filtered or unexported fields
}

func (*Conn) Close Uses

func (c *Conn) Close() error

func (*Conn) LocalAddr Uses

func (c *Conn) LocalAddr() net.Addr

func (*Conn) LocalMultiaddr Uses

func (c *Conn) LocalMultiaddr() ma.Multiaddr

func (*Conn) Read Uses

func (c *Conn) Read(buf []byte) (int, error)

func (*Conn) RemoteAddr Uses

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) RemoteMultiaddr Uses

func (c *Conn) RemoteMultiaddr() ma.Multiaddr

TODO: is it okay to cast c.Conn().RemotePeer() into a multiaddr? might be "user input"

func (*Conn) SetDeadline Uses

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline Uses

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline Uses

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write Uses

func (c *Conn) Write(buf []byte) (int, error)

type NetAddr Uses

type NetAddr struct {
    Relay  string
    Remote string
}

func (*NetAddr) Network Uses

func (n *NetAddr) Network() string

func (*NetAddr) String Uses

func (n *NetAddr) String() string

type Relay Uses

type Relay struct {
    // contains filtered or unexported fields
}

Relay is the relay transport and service.

func NewRelay Uses

func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) (*Relay, error)

NewRelay constructs a new relay.

func (*Relay) CanHop Uses

func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error)

func (*Relay) Dial Uses

func (r *Relay) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (*Conn, error)

func (*Relay) DialPeer Uses

func (r *Relay) DialPeer(ctx context.Context, relay peer.AddrInfo, dest peer.AddrInfo) (*Conn, error)

func (*Relay) GetActiveHops Uses

func (r *Relay) GetActiveHops() int32

func (*Relay) Listener Uses

func (r *Relay) Listener() *RelayListener

func (*Relay) Matches Uses

func (r *Relay) Matches(addr ma.Multiaddr) bool

func (*Relay) Transport Uses

func (r *Relay) Transport() *RelayTransport

type RelayError Uses

type RelayError struct {
    Code pb.CircuitRelay_Status
}

func (RelayError) Error Uses

func (e RelayError) Error() string

type RelayListener Uses

type RelayListener Relay

func (*RelayListener) Accept Uses

func (l *RelayListener) Accept() (manet.Conn, error)

func (*RelayListener) Addr Uses

func (l *RelayListener) Addr() net.Addr

func (*RelayListener) Close Uses

func (l *RelayListener) Close() error

func (*RelayListener) Multiaddr Uses

func (l *RelayListener) Multiaddr() ma.Multiaddr

func (*RelayListener) Relay Uses

func (l *RelayListener) Relay() *Relay

type RelayOpt Uses

type RelayOpt int

RelayOpts are options for configuring the relay transport.

type RelayTransport Uses

type RelayTransport Relay

func (*RelayTransport) CanDial Uses

func (t *RelayTransport) CanDial(raddr ma.Multiaddr) bool

func (*RelayTransport) Dial Uses

func (d *RelayTransport) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (transport.CapableConn, error)

func (*RelayTransport) Listen Uses

func (t *RelayTransport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

func (*RelayTransport) Protocols Uses

func (t *RelayTransport) Protocols() []int

func (*RelayTransport) Proxy Uses

func (t *RelayTransport) Proxy() bool

func (*RelayTransport) Relay Uses

func (t *RelayTransport) Relay() *Relay

Directories

PathSynopsis
pb

Package relay imports 22 packages (graph) and is imported by 50 packages. Updated 2020-12-23. Refresh now. Tools for package owners.