client

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatLimitDuration = statLimitDuration{}
	StatLimitData     = statLimitData{}
)
View Source
var (
	StreamTimeout = 1 * time.Minute
	AcceptTimeout = 10 * time.Second
)
View Source
var DialRelayTimeout = 5 * time.Second
View Source
var DialTimeout = time.Minute
View Source
var HopTagWeight = 5

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

View Source
var ReserveTimeout = time.Minute

Functions

func AddTransport

func AddTransport(h host.Host, upgrader transport.Upgrader) error

AddTransport constructs a new p2p-circuit/v2 client and adds it as a transport to the host network

Types

type Client

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

Client implements the client-side of the p2p-circuit/v2 protocol: - it implements dialing through v2 relays - it listens for incoming connections through v2 relays.

For backwards compatibility with v1 relays and older nodes, the client will also accept relay connections through v1 relays and fallback dial peers using p2p-circuit/v1. This allows us to use the v2 code as drop in replacement for v1 in a host without breaking existing code and interoperability with older nodes.

func New

func New(h host.Host, upgrader transport.Upgrader) (*Client, error)

New constructs a new p2p-circuit/v2 client, attached to the given host and using the given upgrader to perform connection upgrades.

func (*Client) CanDial

func (c *Client) CanDial(addr ma.Multiaddr) bool

func (*Client) Close

func (c *Client) Close() error

func (*Client) Dial

func (*Client) Listen

func (c *Client) Listen(addr ma.Multiaddr) (transport.Listener, error)

func (*Client) Listener

func (c *Client) Listener() *Listener

func (*Client) Protocols

func (c *Client) Protocols() []int

func (*Client) Proxy

func (c *Client) Proxy() bool

func (*Client) Start

func (c *Client) Start()

Start registers the circuit (client) protocol stream handlers

type Conn

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

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

func (*Conn) LocalMultiaddr

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

func (*Conn) Read

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

func (*Conn) RemoteAddr

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

func (*Conn) RemoteMultiaddr

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

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

func (*Conn) SetReadDeadline

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

func (*Conn) SetWriteDeadline

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

func (*Conn) Stat

func (c *Conn) Stat() network.ConnStats

func (*Conn) Write

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

type Listener

type Listener Client

func (*Listener) Accept

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

func (*Listener) Addr

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

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) Multiaddr

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

type NetAddr

type NetAddr struct {
	Relay  string
	Remote string
}

func (*NetAddr) Network

func (n *NetAddr) Network() string

func (*NetAddr) String

func (n *NetAddr) String() string

type Reservation

type Reservation struct {
	// Expiration is the expiration time of the reservation
	Expiration time.Time
	// Addrs contains the vouched public addresses of the reserving peer, which can be
	// announced to the network
	Addrs []ma.Multiaddr

	// LimitDuration is the time limit for which the relay will keep a relayed connection
	// open. If 0, there is no limit.
	LimitDuration time.Duration
	// LimitData is the number of bytes that the relay will relay in each direction before
	// resetting a relayed connection.
	LimitData uint64

	// Voucher is a signed reservation voucher provided by the relay
	Voucher *proto.ReservationVoucher
}

Reservation is a struct carrying information about a relay/v2 slot reservation.

func Reserve

func Reserve(ctx context.Context, h host.Host, ai peer.AddrInfo) (*Reservation, error)

Reserve reserves a slot in a relay and returns the reservation information. Clients must reserve slots in order for the relay to relay connections to them.

type ReservationError

type ReservationError struct {

	// Status is the status returned by the relay for rejecting the reservation
	// request. It is set to pbv2.Status_CONNECTION_FAILED on other failures
	Status pbv2.Status

	// Reason is the reason for reservation failure
	Reason string
	// contains filtered or unexported fields
}

ReservationError is the error returned on failure to reserve a slot in the relay

func (ReservationError) Error

func (re ReservationError) Error() string

func (ReservationError) Unwrap

func (re ReservationError) Unwrap() error

Jump to

Keyboard shortcuts

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