package client
import "github.com/libp2p/go-libp2p/p2p/protocol/circuitv2/client"
Index ¶
- Variables
- func AddTransport(h host.Host, upgrader transport.Upgrader) error
- type Client
- func New(h host.Host, upgrader transport.Upgrader) (*Client, error)
- func (c *Client) CanDial(addr ma.Multiaddr) bool
- func (c *Client) Close() error
- func (c *Client) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
- func (c *Client) Listen(addr ma.Multiaddr) (transport.Listener, error)
- func (c *Client) Listener() *Listener
- func (c *Client) Protocols() []int
- func (c *Client) Proxy() bool
- func (c *Client) SkipResolve(_ context.Context, _ ma.Multiaddr) bool
- func (c *Client) Start()
- 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) Stat() network.ConnStats
- func (c *Conn) Write(buf []byte) (int, error)
- type Listener
- func (l *Listener) Accept() (manet.Conn, error)
- func (l *Listener) Addr() net.Addr
- func (l *Listener) Close() error
- func (l *Listener) Multiaddr() ma.Multiaddr
- type NetAddr
- type Reservation
- type ReservationError
Variables ¶
var ( StatLimitDuration = statLimitDuration{} StatLimitData = statLimitData{} )
var HopTagWeight = 5
HopTagWeight is the connection manager weight for connections carrying relay hop streams
Functions ¶
func AddTransport ¶
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 ¶
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 (*Client) Close ¶
func (*Client) Dial ¶
func (c *Client) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (transport.CapableConn, error)
func (*Client) Listen ¶
func (*Client) Listener ¶
func (*Client) Protocols ¶
func (*Client) Proxy ¶
func (*Client) SkipResolve ¶
SkipResolve returns true since we always defer to the inner transport for the actual connection. By skipping resolution here, we let the inner transport decide how to resolve the multiaddr
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 (*Conn) LocalAddr ¶
func (*Conn) LocalMultiaddr ¶
func (*Conn) Read ¶
func (*Conn) RemoteAddr ¶
func (*Conn) RemoteMultiaddr ¶
TODO: is it okay to cast c.Conn().RemotePeer() into a multiaddr? might be "user input"
func (*Conn) SetDeadline ¶
func (*Conn) SetReadDeadline ¶
func (*Conn) SetWriteDeadline ¶
func (*Conn) Stat ¶
func (*Conn) Write ¶
type Listener ¶
type Listener Client
func (*Listener) Accept ¶
func (*Listener) Addr ¶
func (*Listener) Close ¶
func (*Listener) Multiaddr ¶
type NetAddr ¶
func (*NetAddr) Network ¶
func (*NetAddr) 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 ¶
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
Source Files ¶
client.go conn.go dial.go handlers.go listen.go reservation.go transport.go
- Version
- v0.42.0 (latest)
- Published
- Jun 18, 2025
- Platform
- linux/amd64
- Imports
- 18 packages
- Last checked
- 1 week ago –
Tools for package owners.