tp

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUDPConnNotReady = errors.New("udpConn not ready yet")
)

Functions

func SetModifyDiscoConfig

func SetModifyDiscoConfig(modify func(cfg *DiscoConfig))

Types

type DiscoConfig

type DiscoConfig struct {
	PortScanOffset            int
	PortScanCount             int
	PortScanDuration          time.Duration
	ChallengesRetry           int
	ChallengesInitialInterval time.Duration
	ChallengesBackoffRate     float64
}

type PeerState

type PeerState struct {
	PeerID         disco.PeerID
	Addr           *net.UDPAddr
	LastActiveTime time.Time
}

type PeerStore

type PeerStore interface {
	Peers() []PeerState
}

type UDPConfig

type UDPConfig struct {
	Port                  int
	DisableIPv4           bool
	DisableIPv6           bool
	ID                    disco.PeerID
	PeerKeepaliveInterval time.Duration
	DiscoMagic            func() []byte
}

type UDPConn

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

func ListenUDP

func ListenUDP(cfg UDPConfig) (*UDPConn, error)

func (*UDPConn) Broadcast

func (c *UDPConn) Broadcast(b []byte) (peerCount int, err error)

func (*UDPConn) Close

func (c *UDPConn) Close() error

func (*UDPConn) Datagrams

func (c *UDPConn) Datagrams() <-chan *disco.Datagram

func (*UDPConn) DetectNAT added in v0.7.6

func (c *UDPConn) DetectNAT(stunServers []string) (info disco.NATInfo)

func (*UDPConn) GenerateLocalAddrsSends

func (c *UDPConn) GenerateLocalAddrsSends(peerID disco.PeerID, stunServers []string)

func (*UDPConn) NATEvents added in v0.7.9

func (c *UDPConn) NATEvents() <-chan *disco.NATInfo

func (*UDPConn) Peers

func (c *UDPConn) Peers() (peers []PeerState)

func (*UDPConn) RestartListener

func (c *UDPConn) RestartListener() error

func (*UDPConn) RoundTripSTUN added in v0.7.6

func (c *UDPConn) RoundTripSTUN(stunServer string) (*net.UDPAddr, error)

func (*UDPConn) RunDiscoMessageSendLoop

func (c *UDPConn) RunDiscoMessageSendLoop(udpAddr disco.PeerUDPAddr)

func (*UDPConn) SetReadBuffer

func (c *UDPConn) SetReadBuffer(bytes int) error

SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.

func (*UDPConn) SetWriteBuffer

func (c *UDPConn) SetWriteBuffer(bytes int) error

SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.

func (*UDPConn) UDPAddrSends

func (c *UDPConn) UDPAddrSends() <-chan *disco.PeerUDPAddr

func (*UDPConn) WriteToUDP

func (c *UDPConn) WriteToUDP(p []byte, peerID disco.PeerID) (int, error)

type WSConn

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

func DialPeermap

func DialPeermap(ctx context.Context, server *disco.Peermap, peerID disco.PeerID, metadata url.Values) (*WSConn, error)

func (*WSConn) Close

func (c *WSConn) Close() error

func (*WSConn) Datagrams

func (c *WSConn) Datagrams() <-chan *disco.Datagram

func (*WSConn) LeadDisco

func (c *WSConn) LeadDisco(peerID disco.PeerID) error

func (*WSConn) Peers

func (c *WSConn) Peers() <-chan *disco.Peer

func (*WSConn) PeersUDPAddrs

func (c *WSConn) PeersUDPAddrs() <-chan *disco.PeerUDPAddr

func (*WSConn) Read

func (c *WSConn) Read(p []byte) (n int, err error)

func (*WSConn) Register

func (c *WSConn) Register(ctr disco.Controller)

func (*WSConn) RestartListener

func (c *WSConn) RestartListener() error

func (*WSConn) STUNs

func (c *WSConn) STUNs() []string

func (*WSConn) ServerURL

func (c *WSConn) ServerURL() string

func (*WSConn) Unregister

func (c *WSConn) Unregister(ctr disco.Controller)

func (*WSConn) UpdateNATInfo added in v0.7.9

func (c *WSConn) UpdateNATInfo(natInfo disco.NATInfo) error

func (*WSConn) Write

func (c *WSConn) Write(p []byte) (n int, err error)

func (*WSConn) WriteTo

func (c *WSConn) WriteTo(p []byte, peerID disco.PeerID, op disco.ControlCode) error

Jump to

Keyboard shortcuts

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