disco

package
v0.8.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIgnoredLocalCIDRs

func AddIgnoredLocalCIDRs(cidrs ...string)

func GetIgnoredLocalCIDRs

func GetIgnoredLocalCIDRs() []net.IPNet

func GetIgnoredLocalInterfaceNamePrefixs

func GetIgnoredLocalInterfaceNamePrefixs() []string

func IPIgnored

func IPIgnored(ip net.IP) bool

func ListLocalIPs

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

func MustParseNonce

func MustParseNonce(nonce string) byte

func NewNonce

func NewNonce() string

func RemoveIgnoredLocalCIDRs

func RemoveIgnoredLocalCIDRs(cidrs ...string)

func SetIgnoredLocalCIDRs

func SetIgnoredLocalCIDRs(cidrs ...string)

func SetIgnoredLocalInterfaceNamePrefixs

func SetIgnoredLocalInterfaceNamePrefixs(prefixs ...string)

func SetLocalIPs

func SetLocalIPs(ips ...net.IP)

Types

type ControlCode

type ControlCode uint8
const (
	CONTROL_RELAY                 ControlCode = 0
	CONTROL_NEW_PEER              ControlCode = 1
	CONTROL_NEW_PEER_UDP_ADDR     ControlCode = 2
	CONTROL_LEAD_DISCO            ControlCode = 3
	CONTROL_UPDATE_NETWORK_SECRET ControlCode = 20
	CONTROL_UPDATE_NAT_INFO       ControlCode = 21
	CONTROL_UPDATE_META           ControlCode = 22
	CONTROL_CONN                  ControlCode = 30
)

func (ControlCode) Byte

func (code ControlCode) Byte() byte

func (ControlCode) String

func (code ControlCode) String() string

type Controller

type Controller interface {
	Handle(b []byte)
	Name() string
	Type() uint8
}

type ControllerManager

type ControllerManager interface {
	Register(Controller)
	Unregister(Controller)
}

type Datagram

type Datagram struct {
	PeerID PeerID
	Data   []byte
}

Datagram is the packet from peer or to peer

func (*Datagram) TryDecrypt

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

TryDecrypt the datagram from peer

func (*Datagram) TryEncrypt

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

TryEncrypt the datagram to peer

type Disco

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

func (*Disco) NewPing

func (d *Disco) NewPing(peerID PeerID) []byte

func (*Disco) ParsePing

func (d *Disco) ParsePing(b []byte) PeerID

type Error

type Error struct {
	Code int
	Msg  string
}

func (Error) Error

func (e Error) Error() string

func (Error) MarshalTo

func (e Error) MarshalTo(w io.Writer)

func (Error) Wrap

func (e Error) Wrap(err error) Error

type FileSecretStore

type FileSecretStore struct {
	StoreFilePath string
}

func (*FileSecretStore) NetworkSecret

func (s *FileSecretStore) NetworkSecret() (NetworkSecret, error)

func (*FileSecretStore) UpdateNetworkSecret

func (s *FileSecretStore) UpdateNetworkSecret(secret NetworkSecret) error

type NATInfo

type NATInfo struct {
	Type  NATType
	Addrs []*net.UDPAddr
}

type NATType

type NATType string
const (
	Unknown  NATType = ""
	Hard     NATType = "hard"
	Easy     NATType = "easy"
	UPnP     NATType = "upnp"
	IP4      NATType = "ip4"
	IP6      NATType = "ip6"
	Internal NATType = "internal"
)

func (NATType) AccurateThan

func (t NATType) AccurateThan(t1 NATType) bool

func (NATType) String

func (t NATType) String() string

type NetworkSecret

type NetworkSecret struct {
	Secret  string    `json:"secret"`
	Network string    `json:"network"`
	Expire  time.Time `json:"expire"`
}

func (NetworkSecret) Expired

func (s NetworkSecret) Expired() bool

func (*NetworkSecret) NetworkSecret

func (s *NetworkSecret) NetworkSecret() (NetworkSecret, error)

func (*NetworkSecret) UpdateNetworkSecret

func (s *NetworkSecret) UpdateNetworkSecret(secret NetworkSecret) error

type Peer

type Peer struct {
	ID       PeerID
	Metadata url.Values
}

Peer descibe the peer info

type PeerID

type PeerID string

func (PeerID) Bytes

func (id PeerID) Bytes() []byte

func (PeerID) Len

func (id PeerID) Len() byte

func (PeerID) Network

func (id PeerID) Network() string

func (PeerID) String

func (id PeerID) String() string

type PeerUDPAddr

type PeerUDPAddr struct {
	ID   PeerID
	Addr *net.UDPAddr
	Type NATType
}

PeerUDPAddr describe the peer udp addr

type Peermap

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

func NewPeermap

func NewPeermap(server *url.URL, store SecretStore) (*Peermap, error)

func NewPeermapURL

func NewPeermapURL(serverURL string, store SecretStore) (*Peermap, error)

func (*Peermap) SecretStore

func (s *Peermap) SecretStore() SecretStore

func (*Peermap) String

func (s *Peermap) String() string

type SecretStore

type SecretStore interface {
	NetworkSecret() (NetworkSecret, error)
	UpdateNetworkSecret(NetworkSecret) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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