Documentation ¶
Index ¶
- Constants
- Variables
- func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...Opt) error
- func CanHop(ctx context.Context, host host.Host, id peer.ID) (bool, error)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) LocalMultiaddr() ma.Multiaddr
- func (c *Conn) Read(buf []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) RemoteMultiaddr() ma.Multiaddr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(buf []byte) (int, error)
- type Error
- type Listener
- type NetAddr
- type Notifiee
- func (n *Notifiee) ClosedStream(net inet.Network, s inet.Stream)
- func (n *Notifiee) Connected(s inet.Network, c inet.Conn)
- func (n *Notifiee) Disconnected(s inet.Network, c inet.Conn)
- func (n *Notifiee) Listen(net inet.Network, a ma.Multiaddr)
- func (n *Notifiee) ListenClose(net inet.Network, a ma.Multiaddr)
- func (n *Notifiee) OpenedStream(net inet.Network, s inet.Stream)
- func (n *Notifiee) Relay() *Relay
- type Opt
- type Relay
- func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error)
- func (r *Relay) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (*Conn, error)
- func (r *Relay) DialPeer(ctx context.Context, relay peer.AddrInfo, dest peer.AddrInfo) (*Conn, error)
- func (r *Relay) GetActiveHops() int32
- func (r *Relay) Listener() *Listener
- func (r *Relay) Matches(addr ma.Multiaddr) bool
- func (r *Relay) Transport() *Transport
- type Transport
- func (t *Transport) CanDial(raddr ma.Multiaddr) bool
- func (t *Transport) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (t *Transport) Listen(laddr ma.Multiaddr) (transport.Listener, error)
- func (t *Transport) Protocols() []int
- func (t *Transport) Proxy() bool
- func (t *Transport) Relay() *Relay
Constants ¶
const PCIRCUIT = ma.P_CIRCUIT
PCIRCUIT is deprecated
const ProtoID = "/libp2p/circuit/relay/0.1.0"
ProtoID is the id of the libp2p circuit relay protocol
Variables ¶
var ( // RelayAcceptTimeout defines the relay connection timeout RelayAcceptTimeout = 10 * time.Second // HopConnectTimeout defines when we timeout hops HopConnectTimeout = 30 * time.Second // StopHandshakeTimeout defines a stop handshake timeout StopHandshakeTimeout = 1 * time.Minute // HopStreamBufferSize returns th size of the hop stream buffer HopStreamBufferSize = 4096 // HopStreamLimit returns the maximum number of hops 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 = Opt(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 = Opt(1) // OptDiscovery configures this relay transport to discover new relays // by probing every new peer. You almost _certainly_ don't want to // enable this. OptDiscovery = Opt(2) )
var Protocol = ma.ProtocolWithCode(PCIRCUIT)
Protocol is Deprecated: use ma.ProtocolWithCode(P_CIRCUIT)
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a circuit connection
func (*Conn) LocalMultiaddr ¶
LocalMultiaddr returns th eaddress of the local connection (us)
func (*Conn) RemoteAddr ¶
RemoteAddr returns the address of the remote peer
func (*Conn) RemoteMultiaddr ¶
RemoteMultiaddr TODO: is it okay to cast c.Conn().RemotePeer() into a multiaddr? might be "user input"
func (*Conn) SetDeadline ¶
SetDeadline sets the deadline
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the read deadline
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets the write deadline
type Error ¶
type Error struct {
Code pb.CircuitRelay_Status
}
Error is an error returned from the relay
type Listener ¶
type Listener Relay
Listener is ???
type Notifiee ¶
type Notifiee Relay
Notifiee does ??
func (*Notifiee) ClosedStream ¶
ClosedStream satisfies the network.Notifiee interface
func (*Notifiee) Disconnected ¶
Disconnected satisfies the network.Notifiee interface
func (*Notifiee) ListenClose ¶
ListenClose satisfies the network.Notifiee interface
func (*Notifiee) OpenedStream ¶
OpenedStream satisfies the network.Notifiee interface
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay is the relay transport and service.
func NewRelay ¶
func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...Opt) (*Relay, error)
NewRelay constructs a new relay.
func (*Relay) DialPeer ¶
func (r *Relay) DialPeer(ctx context.Context, relay peer.AddrInfo, dest peer.AddrInfo) (*Conn, error)
DialPeer attempts to dial the given peer
func (*Relay) GetActiveHops ¶
GetActiveHops is used to return the number of active hops
type Transport ¶
type Transport Relay
Transport ??
func (*Transport) Dial ¶
func (t *Transport) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
Dial is used to dial the peer