Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Disco ¶
type Disco interface { AddPeer(pubKey wgkey.DiscoPublicKey) DiscoPeer SetPeers(peers map[wgkey.DiscoPublicKey][]netip.AddrPort) GetAllStatuses() (res map[wgkey.DiscoPublicKey]DiscoPeerStatusReadOnly) Send(pkt *EncryptedDiscoPacket) SetStatusCallback(fn func(pubKey wgkey.DiscoPublicKey, status DiscoPeerStatusReadOnly)) Close() error }
func New ¶
func New( privateKey wgkey.DiscoPrivateKey, packetConn types.PacketConn, logger *zap.Logger, newPeer NewDiscoPeerFunc, newEndpoint NewDiscoPeerEndpointFunc, ) Disco
func NewFromPacketConn ¶
func NewFromPacketConn( privateKey wgkey.DiscoPrivateKey, packetConn types.PacketConn, logger *zap.Logger, ) Disco
type DiscoPacket ¶
type DiscoPacket struct { Header DiscoPacketHeader SrcPublicDiscoKey [32]byte EndpointID uint32 ID uint32 Endpoint netip.AddrPort }
func (*DiscoPacket) Decrypt ¶
func (d *DiscoPacket) Decrypt(encrypted *EncryptedDiscoPacket) bool
func (*DiscoPacket) Encrypt ¶
func (d *DiscoPacket) Encrypt() (*EncryptedDiscoPacket, bool)
type DiscoPacketHeader ¶
type DiscoPacketHeader byte
const ( PingMessage DiscoPacketHeader = 128 + iota PongMessage )
func (DiscoPacketHeader) String ¶
func (d DiscoPacketHeader) String() string
type DiscoPeer ¶
type DiscoPeer interface { EnqueueReceivedPacket(pkt EncryptedDiscoPacket) SetEndpoints(endpoints []netip.AddrPort) Status() DiscoPeerStatus Close() error }
func NewDiscoPeer ¶
func NewDiscoPeer( d Sender, privateKey wgkey.DiscoPrivateKey, pubKey wgkey.DiscoPublicKey, onClose func(), logger *zap.Logger, newEndpoint NewDiscoPeerEndpointFunc, ) DiscoPeer
type DiscoPeerEndpoint ¶
type DiscoPeerEndpoint interface { Endpoint() netip.AddrPort Status() DiscoPeerEndpointStatus SetPriority(priority ticker.Priority) EnqueueReceivedPacket(pkt DiscoPacket) ReceivePing() Close() error }
func NewDiscoPeerEndpoint ¶
func NewDiscoPeerEndpoint( endpointID uint32, endpoint netip.AddrPort, localPubKey wgkey.DiscoPublicKey, sharedKey wgkey.DiscoSharedKey, sender Sender, logger *zap.Logger, ) DiscoPeerEndpoint
type DiscoPeerEndpointStatus ¶
type DiscoPeerEndpointStatus interface { Get() DiscoPeerEndpointStatusReadOnly NotifyStatus(fn func(status DiscoPeerEndpointStatusReadOnly)) }
type DiscoPeerStatus ¶
type DiscoPeerStatus interface { Get() DiscoPeerStatusReadOnly NotifyStatus(fn func(status DiscoPeerStatusReadOnly)) }
type DiscoPeerStatusReadOnly ¶
type EncryptedDiscoPacket ¶
type EncryptedDiscoPacket struct { Header DiscoPacketHeader SrcPublicDiscoKey wgkey.DiscoPublicKey EncryptedPayload []byte Endpoint netip.AddrPort }
func (*EncryptedDiscoPacket) Marshal ¶
func (d *EncryptedDiscoPacket) Marshal() ([]byte, bool)
func (*EncryptedDiscoPacket) Unmarshal ¶
func (d *EncryptedDiscoPacket) Unmarshal(b []byte) bool
type NewDiscoPeerEndpointFunc ¶
type NewDiscoPeerEndpointFunc func( endpointID uint32, endpoint netip.AddrPort, peerPubKey wgkey.DiscoPublicKey, sharedKey wgkey.DiscoSharedKey, sender Sender, logger *zap.Logger, ) DiscoPeerEndpoint
type NewDiscoPeerFunc ¶
type NewDiscoPeerFunc func( d Sender, privateKey wgkey.DiscoPrivateKey, pubKey wgkey.DiscoPublicKey, onClose func(), logger *zap.Logger, newEndpoint NewDiscoPeerEndpointFunc, ) DiscoPeer
type Sender ¶
type Sender interface {
Send(pkt *EncryptedDiscoPacket)
}
Click to show internal directories.
Click to hide internal directories.