Versions in this module Expand all Collapse all v0 v0.29.0 Jul 29, 2023 Changes in this version + const ConcurrentFdDials + const DialAttempts + const PrivateQUICDelay + const PrivateTCPDelay + const PublicQUICDelay + const PublicTCPDelay + const RelayDelay + var BackoffBase = time.Second * 5 + var BackoffCoef = time.Second + var BackoffMax = time.Minute * 5 + var DefaultPerPeerRateLimit = 8 + var ErrAddrFiltered = errors.New("address filtered") + var ErrAllDialsFailed = errors.New("all dials failed") + var ErrConnClosed = errors.New("connection closed") + var ErrDialBackoff = errors.New("dial backoff") + var ErrDialRefusedBlackHole = errors.New("dial refused because of black hole") + var ErrDialTimeout = errors.New("dial timed out") + var ErrDialToSelf = errors.New("dial to self attempted") + var ErrGaterDisallowedConnection = errors.New("gater disallows connection to peer") + var ErrNoAddresses = errors.New("no addresses") + var ErrNoGoodAddresses = errors.New("no good addresses") + var ErrNoTransport = errors.New("no transport for protocol") + var ErrSwarmClosed = errors.New("swarm closed") + func DefaultDialRanker(addrs []ma.Multiaddr) []network.AddrDelay + func NoDelayDialRanker(addrs []ma.Multiaddr) []network.AddrDelay + type Clock interface + InstantTimer func(when time.Time) InstantTimer + Now func() time.Time + Since func(t time.Time) time.Duration + type Conn struct + func (c *Conn) Close() error + func (c *Conn) ConnState() network.ConnectionState + func (c *Conn) GetStreams() []network.Stream + func (c *Conn) ID() string + func (c *Conn) IsClosed() bool + func (c *Conn) LocalMultiaddr() ma.Multiaddr + func (c *Conn) LocalPeer() peer.ID + func (c *Conn) NewStream(ctx context.Context) (network.Stream, error) + func (c *Conn) RemoteMultiaddr() ma.Multiaddr + func (c *Conn) RemotePeer() peer.ID + func (c *Conn) RemotePublicKey() ic.PubKey + func (c *Conn) Scope() network.ConnScope + func (c *Conn) Stat() network.ConnStats + func (c *Conn) String() string + type DialBackoff struct + func (db *DialBackoff) AddBackoff(p peer.ID, addr ma.Multiaddr) + func (db *DialBackoff) Backoff(p peer.ID, addr ma.Multiaddr) (backoff bool) + func (db *DialBackoff) Clear(p peer.ID) + type DialError struct + Cause error + DialErrors []TransportError + Peer peer.ID + Skipped int + func (e *DialError) Error() string + func (e *DialError) Timeout() bool + func (e *DialError) Unwrap() error + type InstantTimer interface + Ch func() <-chan time.Time + Reset func(d time.Time) bool + Stop func() bool + type MetricsTracer interface + ClosedConnection func(network.Direction, time.Duration, network.ConnectionState, ma.Multiaddr) + CompletedHandshake func(time.Duration, network.ConnectionState, ma.Multiaddr) + DialCompleted func(success bool, totalDials int) + DialRankingDelay func(d time.Duration) + FailedDialing func(ma.Multiaddr, error) + OpenedConnection func(network.Direction, crypto.PubKey, network.ConnectionState, ma.Multiaddr) + UpdatedBlackHoleFilterState func(name string, state blackHoleState, nextProbeAfter int, successFraction float64) + func NewMetricsTracer(opts ...MetricsTracerOption) MetricsTracer + type MetricsTracerOption func(*metricsTracerSetting) + func WithRegisterer(reg prometheus.Registerer) MetricsTracerOption + type Option func(*Swarm) error + func WithConnectionGater(gater connmgr.ConnectionGater) Option + func WithDialRanker(d network.DialRanker) Option + func WithDialTimeout(t time.Duration) Option + func WithDialTimeoutLocal(t time.Duration) Option + func WithIPv6BlackHoleConfig(enabled bool, n, min int) Option + func WithMetrics(reporter metrics.Reporter) Option + func WithMetricsTracer(t MetricsTracer) Option + func WithMultiaddrResolver(maResolver *madns.Resolver) Option + func WithResourceManager(m network.ResourceManager) Option + func WithUDPBlackHoleConfig(enabled bool, n, min int) Option + type RealClock struct + func (RealClock) InstantTimer(when time.Time) InstantTimer + func (RealClock) Now() time.Time + func (RealClock) Since(t time.Time) time.Duration + type RealTimer struct + func (t RealTimer) Ch() <-chan time.Time + func (t RealTimer) Reset(d time.Time) bool + func (t RealTimer) Stop() bool + type Stream struct + func (s *Stream) Close() error + func (s *Stream) CloseRead() error + func (s *Stream) CloseWrite() error + func (s *Stream) Conn() network.Conn + func (s *Stream) ID() string + func (s *Stream) Protocol() protocol.ID + func (s *Stream) Read(p []byte) (int, error) + func (s *Stream) Reset() error + func (s *Stream) Scope() network.StreamScope + func (s *Stream) SetDeadline(t time.Time) error + func (s *Stream) SetProtocol(p protocol.ID) error + func (s *Stream) SetReadDeadline(t time.Time) error + func (s *Stream) SetWriteDeadline(t time.Time) error + func (s *Stream) Stat() network.Stats + func (s *Stream) String() string + func (s *Stream) Write(p []byte) (int, error) + type Swarm struct + func NewSwarm(local peer.ID, peers peerstore.Peerstore, eventBus event.Bus, opts ...Option) (*Swarm, error) + func (s *Swarm) AddListenAddr(a ma.Multiaddr) error + func (s *Swarm) AddTransport(t transport.Transport) error + func (s *Swarm) Backoff() *DialBackoff + func (s *Swarm) Close() error + func (s *Swarm) ClosePeer(p peer.ID) error + func (s *Swarm) Connectedness(p peer.ID) network.Connectedness + func (s *Swarm) Conns() []network.Conn + func (s *Swarm) ConnsToPeer(p peer.ID) []network.Conn + func (s *Swarm) DialPeer(ctx context.Context, p peer.ID) (network.Conn, error) + func (s *Swarm) InterfaceListenAddresses() ([]ma.Multiaddr, error) + func (s *Swarm) Listen(addrs ...ma.Multiaddr) error + func (s *Swarm) ListenAddresses() []ma.Multiaddr + func (s *Swarm) ListenClose(addrs ...ma.Multiaddr) + func (s *Swarm) LocalPeer() peer.ID + func (s *Swarm) NewStream(ctx context.Context, p peer.ID) (network.Stream, error) + func (s *Swarm) Notify(f network.Notifiee) + func (s *Swarm) Peers() []peer.ID + func (s *Swarm) Peerstore() peerstore.Peerstore + func (s *Swarm) ResourceManager() network.ResourceManager + func (s *Swarm) SetStreamHandler(handler network.StreamHandler) + func (s *Swarm) StopNotify(f network.Notifiee) + func (s *Swarm) StreamHandler() network.StreamHandler + func (s *Swarm) String() string + func (s *Swarm) TransportForDialing(a ma.Multiaddr) transport.Transport + func (s *Swarm) TransportForListening(a ma.Multiaddr) transport.Transport + type TransportError struct + Address ma.Multiaddr + Cause error + func (e *TransportError) Error() string