disco

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUseOfClosedConnection error = errors.New("use of closed network connection")
)

Functions

func AddIgnoredLocalCIDRs added in v0.0.2

func AddIgnoredLocalCIDRs(cidrs ...string)

func ListLocalIPs

func ListLocalIPs() ([]net.IP, error)

func SetIgnoredLocalCIDRs

func SetIgnoredLocalCIDRs(cidrs ...string)

func SetIgnoredLocalInterfaceNamePrefixs

func SetIgnoredLocalInterfaceNamePrefixs(prefixs ...string)

func SetLocalIPs added in v0.0.2

func SetLocalIPs(ips ...net.IP)

func SetModifyDiscoConfig added in v0.0.2

func SetModifyDiscoConfig(modify func(cfg *DiscoConfig))

func SetNetwotkDetectInterval added in v0.2.3

func SetNetwotkDetectInterval(interval time.Duration)

Types

type Datagram

type Datagram struct {
	PeerID peer.ID
	Data   []byte
}

func (*Datagram) TryDecrypt

func (d *Datagram) TryDecrypt(symmAlgo secure.SymmAlgo) []byte

func (*Datagram) TryEncrypt

func (d *Datagram) TryEncrypt(symmAlgo secure.SymmAlgo) []byte

type Disco added in v0.2.3

type Disco struct {
	Magic func() []byte
}

func (*Disco) NewPing added in v0.2.3

func (d *Disco) NewPing(peerID peer.ID) []byte

func (*Disco) ParsePing added in v0.2.3

func (d *Disco) ParsePing(b []byte) peer.ID

type DiscoConfig added in v0.0.2

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

type PeerContext

type PeerContext struct {
	PeerID     peer.ID
	States     map[string]*PeerState
	CreateTime time.Time
	// contains filtered or unexported fields
}

func (*PeerContext) Close added in v0.0.2

func (peer *PeerContext) Close() error

func (*PeerContext) Healthcheck added in v0.0.2

func (peer *PeerContext) Healthcheck()

func (*PeerContext) Heartbeat added in v0.0.2

func (peer *PeerContext) Heartbeat(addr *net.UDPAddr)

func (*PeerContext) IPv4Ready

func (peer *PeerContext) IPv4Ready() bool

func (*PeerContext) Keepalive added in v0.0.2

func (peer *PeerContext) Keepalive()

func (*PeerContext) Ready

func (peer *PeerContext) Ready() bool

func (*PeerContext) Select

func (peer *PeerContext) Select() *net.UDPAddr

type PeerFindEvent

type PeerFindEvent struct {
	PeerID   peer.ID
	Metadata peer.Metadata
}

type PeerState

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

type PeerStore added in v0.0.2

type PeerStore interface {
	FindPeer(peer.ID) (*PeerContext, bool)
}

type PeerUDPAddrEvent

type PeerUDPAddrEvent struct {
	PeerID peer.ID
	Addr   *net.UDPAddr
}

type STUNSession

type STUNSession struct {
	PeerID peer.ID
	CTime  time.Time
}

type UDPConn

type UDPConn struct {
	*net.UDPConn
	// contains filtered or unexported fields
}

func ListenUDP

func ListenUDP(port int, disableIPv4, disableIPv6 bool, id peer.ID) (*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 *Datagram

func (*UDPConn) FindPeer added in v0.0.2

func (c *UDPConn) FindPeer(peerID peer.ID) (*PeerContext, bool)

func (*UDPConn) GenerateLocalAddrsSends

func (c *UDPConn) GenerateLocalAddrsSends(peerID peer.ID, stunServers []string)

func (*UDPConn) NetworkChangedEvents added in v0.2.1

func (c *UDPConn) NetworkChangedEvents() <-chan struct{}

func (*UDPConn) RunDiscoMessageSendLoop

func (c *UDPConn) RunDiscoMessageSendLoop(peerID peer.ID, addr *net.UDPAddr)

func (*UDPConn) SetKeepAlivePeriod added in v0.0.2

func (c *UDPConn) SetKeepAlivePeriod(period time.Duration)

SetKeepAlivePeriod set udp keepalive period

func (*UDPConn) UDPAddrSends

func (c *UDPConn) UDPAddrSends() <-chan *PeerUDPAddrEvent

func (*UDPConn) WriteToUDP

func (n *UDPConn) WriteToUDP(p []byte, peerID peer.ID) (int, error)

type WSConn

type WSConn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func DialPeermap added in v0.2.3

func DialPeermap(peermap *peermap.Peermap, peerID peer.ID, metadata peer.Metadata) (*WSConn, error)

func (*WSConn) Close

func (c *WSConn) Close() error

func (*WSConn) CloseConn added in v0.2.3

func (c *WSConn) CloseConn() error

func (*WSConn) Datagrams

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

func (*WSConn) LeadDisco added in v0.0.2

func (c *WSConn) LeadDisco(peerID peer.ID) error

func (*WSConn) Peers

func (c *WSConn) Peers() <-chan *PeerFindEvent

func (*WSConn) PeersUDPAddrs

func (c *WSConn) PeersUDPAddrs() <-chan *PeerUDPAddrEvent

func (*WSConn) STUNs added in v0.0.2

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

func (*WSConn) WriteTo

func (c *WSConn) WriteTo(p []byte, peerID peer.ID, op byte) error

Jump to

Keyboard shortcuts

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