Documentation ¶
Index ¶
- Constants
- func GetRandomPort(args ...int) int
- func RandomBytes(len int) []byte
- type BaseService
- type Config
- type DiscoveryDHT
- type HttpService
- type InterfaceService
- type ListenerService
- type LocalNode
- func (n *LocalNode) AddService(srv Service)
- func (n *LocalNode) Config() Config
- func (n *LocalNode) NetTable() *NetTable
- func (n *LocalNode) NetworkSecret() *secure.NetworkSecret
- func (n *LocalNode) Service(name string) Service
- func (n *LocalNode) Start() error
- func (n *LocalNode) State() State
- func (n *LocalNode) Stop() error
- func (n *LocalNode) WaitStop()
- type NetTable
- func (nt *NetTable) AddRemoteNode(rn *RemoteNode)
- func (nt *NetTable) GetDHTInChannel() chan<- string
- func (nt *NetTable) Init(ln *LocalNode) error
- func (nt NetTable) Name() string
- func (nt *NetTable) PeerAddresses() map[string]string
- func (nt *NetTable) RemoteNodeByIP(ip net.IP) *RemoteNode
- func (nt *NetTable) RemoveRemoteNode(ip net.IP)
- func (nt *NetTable) Run() error
- func (nt *NetTable) SendPacket(dstIP net.IP, payload []byte)
- func (nt *NetTable) Stop()
- type Node
- type NodeSet
- type NodeSetElement
- type RemoteNode
- type Response
- type STUNService
- type Service
- type State
- type UPnPService
Constants ¶
View Source
const ( StatusCreated = iota StatusRunned StatusStopping StatusStopped )
View Source
const (
STUNAddress = "stun.l.google.com:19302"
)
Variables ¶
This section is empty.
Functions ¶
func GetRandomPort ¶
func RandomBytes ¶
Types ¶
type BaseService ¶
type BaseService struct { Service // contains filtered or unexported fields }
func (*BaseService) IsNeedStop ¶
func (s *BaseService) IsNeedStop() bool
func (*BaseService) SetStatus ¶
func (s *BaseService) SetStatus(v uint32)
func (*BaseService) Status ¶
func (s *BaseService) Status() uint32
func (*BaseService) Stop ¶
func (s *BaseService) Stop()
type DiscoveryDHT ¶
type DiscoveryDHT struct { BaseService // contains filtered or unexported fields }
func (*DiscoveryDHT) Init ¶
func (d *DiscoveryDHT) Init(ln *LocalNode) error
func (DiscoveryDHT) Name ¶
func (d DiscoveryDHT) Name() string
func (*DiscoveryDHT) Run ¶
func (d *DiscoveryDHT) Run() error
func (*DiscoveryDHT) Stop ¶
func (d *DiscoveryDHT) Stop()
type HttpService ¶
type HttpService struct { BaseService // contains filtered or unexported fields }
func (*HttpService) Init ¶
func (hs *HttpService) Init(ln *LocalNode) (err error)
func (*HttpService) Name ¶
func (hs *HttpService) Name() string
func (*HttpService) Run ¶
func (hs *HttpService) Run() error
type InterfaceService ¶
type InterfaceService struct { BaseService // contains filtered or unexported fields }
func (*InterfaceService) Init ¶
func (is *InterfaceService) Init(ln *LocalNode) (err error)
func (*InterfaceService) Name ¶
func (is *InterfaceService) Name() string
func (*InterfaceService) Run ¶
func (is *InterfaceService) Run() error
func (*InterfaceService) WritePacket ¶
func (is *InterfaceService) WritePacket(packet []byte)
type ListenerService ¶
type ListenerService struct { BaseService // contains filtered or unexported fields }
func (*ListenerService) Init ¶
func (l *ListenerService) Init(ln *LocalNode) error
func (ListenerService) Name ¶
func (l ListenerService) Name() string
func (*ListenerService) Run ¶
func (l *ListenerService) Run() error
func (*ListenerService) Stop ¶
func (l *ListenerService) Stop()
type LocalNode ¶
type LocalNode struct { Node // contains filtered or unexported fields }
func NewLocalNode ¶
func (*LocalNode) AddService ¶
func (*LocalNode) NetworkSecret ¶
func (n *LocalNode) NetworkSecret() *secure.NetworkSecret
type NetTable ¶
type NetTable struct { BaseService // contains filtered or unexported fields }
func (*NetTable) AddRemoteNode ¶
func (nt *NetTable) AddRemoteNode(rn *RemoteNode)
func (*NetTable) GetDHTInChannel ¶
func (*NetTable) PeerAddresses ¶
func (*NetTable) RemoteNodeByIP ¶
func (nt *NetTable) RemoteNodeByIP(ip net.IP) *RemoteNode
func (*NetTable) RemoveRemoteNode ¶
type NodeSet ¶
type NodeSet struct {
// contains filtered or unexported fields
}
func NewNodeSet ¶
func NewNodeSet() *NodeSet
func (*NodeSet) Data ¶
func (s *NodeSet) Data() map[string]NodeSetElement
func (*NodeSet) Merge ¶
func (s *NodeSet) Merge(values map[string]NodeSetElement)
type NodeSetElement ¶
func (NodeSetElement) String ¶
func (ne NodeSetElement) String() string
type RemoteNode ¶
type RemoteNode struct { Node // contains filtered or unexported fields }
func NewRemoteNode ¶
func TryConnect ¶
func TryConnect(h string, networkSecret *secure.NetworkSecret, ln *LocalNode) (*RemoteNode, error)
func (*RemoteNode) Close ¶
func (rn *RemoteNode) Close()
func (*RemoteNode) SendToInterface ¶
func (rn *RemoteNode) SendToInterface(payload []byte) error
type STUNService ¶
type STUNService struct { BaseService // contains filtered or unexported fields }
func (*STUNService) Init ¶
func (s *STUNService) Init(ln *LocalNode) error
func (STUNService) Name ¶
func (d STUNService) Name() string
func (*STUNService) Run ¶
func (s *STUNService) Run() error
type State ¶
type State struct { Secret *secure.NetworkSecret `json:"-"` ListenPort int `json:"port"` PrivateIP net.IP `json:"private_ip"` // contains filtered or unexported fields }
func NewState ¶
func NewState(secret *secure.NetworkSecret) *State
type UPnPService ¶
type UPnPService struct { BaseService // contains filtered or unexported fields }
func (*UPnPService) Init ¶
func (s *UPnPService) Init(ln *LocalNode) error
func (UPnPService) Name ¶
func (d UPnPService) Name() string
func (*UPnPService) Run ¶
func (s *UPnPService) Run() error
Click to show internal directories.
Click to hide internal directories.