Documentation
¶
Overview ¶
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024-2026 Quad4.io
WebSocketInterface is a native implementation of the WebSocket interface. It is used to connect to the WebSocket server and send/receive data.
Index ¶
- Constants
- type AdoptedInterface
- type AutoInterface
- type BaseInterface
- func (i *BaseInterface) Detach()
- func (i *BaseInterface) Disable()
- func (i *BaseInterface) Enable()
- func (i *BaseInterface) GetBandwidthAvailable() bool
- func (i *BaseInterface) GetConn() net.Conn
- func (i *BaseInterface) GetIFAC() common.IFAC
- func (i *BaseInterface) GetMTU() int
- func (i *BaseInterface) GetMode() common.InterfaceMode
- func (i *BaseInterface) GetName() string
- func (i *BaseInterface) GetPacketCallback() common.PacketCallback
- func (i *BaseInterface) GetRxBytes() uint64
- func (i *BaseInterface) GetRxPackets() uint64
- func (i *BaseInterface) GetTxBytes() uint64
- func (i *BaseInterface) GetTxPackets() uint64
- func (i *BaseInterface) GetType() common.InterfaceType
- func (i *BaseInterface) IsDetached() bool
- func (i *BaseInterface) IsEnabled() bool
- func (i *BaseInterface) IsOnline() bool
- func (i *BaseInterface) ProcessIncoming(data []byte)
- func (i *BaseInterface) ProcessOutgoing(data []byte) error
- func (i *BaseInterface) Send(data []byte, address string) error
- func (i *BaseInterface) SendLinkPacket(dest []byte, data []byte, timestamp time.Time) error
- func (i *BaseInterface) SendPathRequest(packet []byte) error
- func (i *BaseInterface) SetIFAC(id common.IFAC)
- func (i *BaseInterface) SetPacketCallback(callback common.PacketCallback)
- func (i *BaseInterface) Start() error
- func (i *BaseInterface) Stop() error
- type DequeEntry
- type InterceptedInterface
- type Interface
- type Peer
- type TCPClientInterface
- func (tc *TCPClientInterface) Disable()
- func (tc *TCPClientInterface) Enable()
- func (tc *TCPClientInterface) GetName() string
- func (tc *TCPClientInterface) GetPacketCallback() common.PacketCallback
- func (tc *TCPClientInterface) GetRTT() time.Duration
- func (tc *TCPClientInterface) IsConnected() bool
- func (tc *TCPClientInterface) IsDetached() bool
- func (tc *TCPClientInterface) IsEnabled() bool
- func (tc *TCPClientInterface) IsOnline() bool
- func (tc *TCPClientInterface) ProcessOutgoing(data []byte) error
- func (tc *TCPClientInterface) Send(data []byte, address string) error
- func (tc *TCPClientInterface) SetPacketCallback(cb common.PacketCallback)
- func (tc *TCPClientInterface) Start() error
- func (tc *TCPClientInterface) Stop() error
- type TCPServerInterface
- func (ts *TCPServerInterface) Disable()
- func (ts *TCPServerInterface) Enable()
- func (ts *TCPServerInterface) GetName() string
- func (ts *TCPServerInterface) GetPacketCallback() common.PacketCallback
- func (ts *TCPServerInterface) IsDetached() bool
- func (ts *TCPServerInterface) IsEnabled() bool
- func (ts *TCPServerInterface) IsOnline() bool
- func (ts *TCPServerInterface) ProcessOutgoing(data []byte) error
- func (ts *TCPServerInterface) Send(data []byte, address string) error
- func (ts *TCPServerInterface) SetPacketCallback(callback common.PacketCallback)
- func (ts *TCPServerInterface) Start() error
- func (ts *TCPServerInterface) Stop() error
- func (ts *TCPServerInterface) String() string
- type UDPInterface
- func (ui *UDPInterface) Detach()
- func (ui *UDPInterface) Disable()
- func (ui *UDPInterface) Enable()
- func (ui *UDPInterface) GetBitrate() int
- func (ui *UDPInterface) GetConn() net.Conn
- func (ui *UDPInterface) GetMTU() int
- func (ui *UDPInterface) GetMode() common.InterfaceMode
- func (ui *UDPInterface) GetName() string
- func (ui *UDPInterface) GetPacketCallback() common.PacketCallback
- func (ui *UDPInterface) GetRxBytes() uint64
- func (ui *UDPInterface) GetTxBytes() uint64
- func (ui *UDPInterface) GetType() common.InterfaceType
- func (ui *UDPInterface) IsDetached() bool
- func (ui *UDPInterface) IsEnabled() bool
- func (ui *UDPInterface) IsOnline() bool
- func (ui *UDPInterface) ProcessIncoming(data []byte)
- func (ui *UDPInterface) ProcessOutgoing(data []byte) error
- func (ui *UDPInterface) Send(data []byte, address string) error
- func (ui *UDPInterface) SetPacketCallback(callback common.PacketCallback)
- func (ui *UDPInterface) Start() error
- func (ui *UDPInterface) Stop() error
- type WebSocketInterface
- func (wsi *WebSocketInterface) Detach()
- func (wsi *WebSocketInterface) Disable()
- func (wsi *WebSocketInterface) Enable()
- func (wsi *WebSocketInterface) GetBandwidthAvailable() bool
- func (wsi *WebSocketInterface) GetConn() net.Conn
- func (wsi *WebSocketInterface) GetMTU() int
- func (wsi *WebSocketInterface) GetMode() common.InterfaceMode
- func (wsi *WebSocketInterface) GetName() string
- func (wsi *WebSocketInterface) GetType() common.InterfaceType
- func (wsi *WebSocketInterface) IsDetached() bool
- func (wsi *WebSocketInterface) IsEnabled() bool
- func (wsi *WebSocketInterface) IsOnline() bool
- func (wsi *WebSocketInterface) ProcessOutgoing(data []byte) error
- func (wsi *WebSocketInterface) Send(data []byte, addr string) error
- func (wsi *WebSocketInterface) SendLinkPacket(dest []byte, data []byte, timestamp time.Time) error
- func (wsi *WebSocketInterface) SendPathRequest(packet []byte) error
- func (wsi *WebSocketInterface) Start() error
- func (wsi *WebSocketInterface) Stop() error
Constants ¶
const ( BitrateMinimum = 1200 ModeFull = 0x01 ModeGateway = 0x02 ModeAccessPoint = 0x03 ModeRoaming = 0x04 ModeBoundary = 0x05 TypeUDP = 0x01 TypeTCP = 0x02 PropagationRate = 0.02 )
const ( HDLCFlag = 0x7E HDLCEsc = 0x7D HDLCEscMask = 0x20 KISSFend = 0xC0 KISSFesc = 0xDB KISSTFend = 0xDC KISSTFesc = 0xDD DefaultMTU = 1064 BitrateGuessVal = 10 * 1000 * 1000 ReconnectWait = 5 InitialTimeout = 5 InitialBackoff = time.Second MaxBackoff = time.Minute * 5 TCPUserTimeoutSec = 24 TCPProbeAfterSec = 5 TCPProbeIntervalSec = 2 TCPProbesCount = 12 TCPConnectTimeout = 10 * time.Second TCPMilliseconds = 1000 I2PUserTimeoutSec = 45 I2PProbeAfterSec = 10 I2PProbeIntervalSec = 9 I2PProbesCount = 5 SOKeepaliveEnable = 1 )
const ( HWMTU = 1196 DefaultDiscoveryPort = 29716 DefaultDataPort = 42671 DefaultGroupID = "reticulum" BitrateGuess = 10 * 1000 * 1000 PeeringTimeout = 22 * time.Second AnnounceInterval = 1600 * time.Millisecond PeerJobInterval = 4 * time.Second McastEchoTimeout = 6500 * time.Millisecond ScopeLink = "2" ScopeAdmin = "4" ScopeSite = "5" ScopeOrganisation = "8" ScopeGlobal = "e" McastAddrTypePermanent = "0" McastAddrTypeTemporary = "1" MultiIFDequeLen = 48 MultiIFDequeTTL = 750 * time.Millisecond )
const ( WSMTU = 1064 // MaxWSControlPayload caps ping/pong/close control frame payloads (defense in depth). MaxWSControlPayload = 4096 WSBitrate = 10000000 WSReconnectDelay = 2 * time.Second )
const ( WSBufferSize = 4096 WSHTTPSPort = 443 WSHTTPPort = 80 WSVersion = "13" WSConnectTimeout = 10 * time.Second WSKeySize = 16 WSMaskKeySize = 4 WSHeaderSize = 2 WSPayloadLen16Bit = 126 WSPayloadLen64Bit = 127 WSMaxPayload16Bit = 65536 WSFrameHeaderFin = 0x80 WSFrameHeaderOpcode = 0x0F WSFrameHeaderMasked = 0x80 WSFrameHeaderLen = 0x7F WSOpcodeContinuation = 0x00 WSOpcodeText = 0x01 WSOpcodeBinary = 0x02 WSOpcodeClose = 0x08 WSOpcodePing = 0x09 WSOpcodePong = 0x0A )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdoptedInterface ¶
type AdoptedInterface struct {
// contains filtered or unexported fields
}
type AutoInterface ¶
type AutoInterface struct {
BaseInterface
// contains filtered or unexported fields
}
func NewAutoInterface ¶
func NewAutoInterface(name string, config *common.InterfaceConfig) (*AutoInterface, error)
func (*AutoInterface) PeerCount ¶ added in v0.9.5
func (ai *AutoInterface) PeerCount() int
PeerCount returns the number of currently known peers.
func (*AutoInterface) Start ¶
func (ai *AutoInterface) Start() error
func (*AutoInterface) Stop ¶
func (ai *AutoInterface) Stop() error
type BaseInterface ¶
type BaseInterface struct {
Name string
Mode common.InterfaceMode
Type common.InterfaceType
Online bool
Enabled bool
Detached bool
In bool
Out bool
MTU int
Bitrate int64
TxBytes uint64
RxBytes uint64
TxPackets uint64
RxPackets uint64
Mutex sync.RWMutex
// IFACIdentity is set when the interface participates in an IFAC network.
// When non-nil, outbound packets are masked before transmit and inbound
// packets are unmasked and verified; unauthenticated packets are dropped.
IFACIdentity common.IFAC
// contains filtered or unexported fields
}
func NewBaseInterface ¶
func NewBaseInterface(name string, ifType common.InterfaceType, enabled bool) BaseInterface
func (*BaseInterface) Detach ¶
func (i *BaseInterface) Detach()
func (*BaseInterface) Disable ¶
func (i *BaseInterface) Disable()
func (*BaseInterface) Enable ¶
func (i *BaseInterface) Enable()
func (*BaseInterface) GetBandwidthAvailable ¶
func (i *BaseInterface) GetBandwidthAvailable() bool
func (*BaseInterface) GetConn ¶
func (i *BaseInterface) GetConn() net.Conn
func (*BaseInterface) GetIFAC ¶ added in v0.9.0
func (i *BaseInterface) GetIFAC() common.IFAC
GetIFAC returns the configured Interface Access Code identity, or nil if IFAC is disabled.
func (*BaseInterface) GetMTU ¶
func (i *BaseInterface) GetMTU() int
func (*BaseInterface) GetMode ¶
func (i *BaseInterface) GetMode() common.InterfaceMode
func (*BaseInterface) GetName ¶
func (i *BaseInterface) GetName() string
func (*BaseInterface) GetPacketCallback ¶
func (i *BaseInterface) GetPacketCallback() common.PacketCallback
func (*BaseInterface) GetRxBytes ¶ added in v0.9.0
func (i *BaseInterface) GetRxBytes() uint64
func (*BaseInterface) GetRxPackets ¶ added in v0.9.0
func (i *BaseInterface) GetRxPackets() uint64
func (*BaseInterface) GetTxBytes ¶ added in v0.9.0
func (i *BaseInterface) GetTxBytes() uint64
func (*BaseInterface) GetTxPackets ¶ added in v0.9.0
func (i *BaseInterface) GetTxPackets() uint64
func (*BaseInterface) GetType ¶
func (i *BaseInterface) GetType() common.InterfaceType
func (*BaseInterface) IsDetached ¶
func (i *BaseInterface) IsDetached() bool
func (*BaseInterface) IsEnabled ¶
func (i *BaseInterface) IsEnabled() bool
func (*BaseInterface) IsOnline ¶
func (i *BaseInterface) IsOnline() bool
func (*BaseInterface) ProcessIncoming ¶
func (i *BaseInterface) ProcessIncoming(data []byte)
func (*BaseInterface) ProcessOutgoing ¶
func (i *BaseInterface) ProcessOutgoing(data []byte) error
ProcessOutgoing on the abstract BaseInterface is intentionally a fail-loud stub: any concrete network interface that uses BaseInterface as its base MUST override ProcessOutgoing to actually transmit bytes. Returning an error (and logging at CRITICAL) surfaces dynamic-dispatch mistakes (e.g. a *BaseInterface pointer leaking through a callback closure) instead of letting the transport silently swallow every outgoing packet.
func (*BaseInterface) SendLinkPacket ¶
func (*BaseInterface) SendPathRequest ¶
func (i *BaseInterface) SendPathRequest(packet []byte) error
func (*BaseInterface) SetIFAC ¶ added in v0.9.0
func (i *BaseInterface) SetIFAC(id common.IFAC)
SetIFAC stores an Interface Access Code identity on this interface. Pass nil to disable IFAC. Subsequent Send / ProcessIncoming calls will use the new value.
func (*BaseInterface) SetPacketCallback ¶
func (i *BaseInterface) SetPacketCallback(callback common.PacketCallback)
func (*BaseInterface) Start ¶
func (i *BaseInterface) Start() error
func (*BaseInterface) Stop ¶
func (i *BaseInterface) Stop() error
type DequeEntry ¶ added in v0.9.0
type DequeEntry struct {
// contains filtered or unexported fields
}
type InterceptedInterface ¶
type InterceptedInterface struct {
Interface
// contains filtered or unexported fields
}
func NewInterceptedInterface ¶
func NewInterceptedInterface(base Interface, interceptor func([]byte, common.NetworkInterface) error) *InterceptedInterface
Create constructor for intercepted interface
type Interface ¶
type Interface interface {
GetName() string
GetType() common.InterfaceType
GetMode() common.InterfaceMode
IsOnline() bool
IsDetached() bool
IsEnabled() bool
Detach()
Enable()
Disable()
Send(data []byte, addr string) error
SetPacketCallback(common.PacketCallback)
GetPacketCallback() common.PacketCallback
ProcessIncoming([]byte)
ProcessOutgoing([]byte) error
SendPathRequest([]byte) error
SendLinkPacket([]byte, []byte, time.Time) error
Start() error
Stop() error
GetMTU() int
GetConn() net.Conn
GetBandwidthAvailable() bool
common.NetworkInterface
}
func NewFromConfig ¶ added in v0.9.2
func NewFromConfig(name string, cfg *common.InterfaceConfig) (Interface, error)
NewFromConfig constructs a logical interface from a loaded common.InterfaceConfig.
type TCPClientInterface ¶
type TCPClientInterface struct {
BaseInterface
// contains filtered or unexported fields
}
func NewTCPClientInterface ¶
func (*TCPClientInterface) Disable ¶
func (tc *TCPClientInterface) Disable()
func (*TCPClientInterface) Enable ¶
func (tc *TCPClientInterface) Enable()
func (*TCPClientInterface) GetName ¶
func (tc *TCPClientInterface) GetName() string
func (*TCPClientInterface) GetPacketCallback ¶
func (tc *TCPClientInterface) GetPacketCallback() common.PacketCallback
func (*TCPClientInterface) GetRTT ¶
func (tc *TCPClientInterface) GetRTT() time.Duration
func (*TCPClientInterface) IsConnected ¶
func (tc *TCPClientInterface) IsConnected() bool
func (*TCPClientInterface) IsDetached ¶
func (tc *TCPClientInterface) IsDetached() bool
func (*TCPClientInterface) IsEnabled ¶
func (tc *TCPClientInterface) IsEnabled() bool
func (*TCPClientInterface) IsOnline ¶
func (tc *TCPClientInterface) IsOnline() bool
func (*TCPClientInterface) ProcessOutgoing ¶
func (tc *TCPClientInterface) ProcessOutgoing(data []byte) error
func (*TCPClientInterface) Send ¶
func (tc *TCPClientInterface) Send(data []byte, address string) error
func (*TCPClientInterface) SetPacketCallback ¶
func (tc *TCPClientInterface) SetPacketCallback(cb common.PacketCallback)
func (*TCPClientInterface) Start ¶
func (tc *TCPClientInterface) Start() error
func (*TCPClientInterface) Stop ¶ added in v0.9.0
func (tc *TCPClientInterface) Stop() error
type TCPServerInterface ¶
type TCPServerInterface struct {
BaseInterface
// contains filtered or unexported fields
}
func NewTCPServerInterface ¶
func (*TCPServerInterface) Disable ¶
func (ts *TCPServerInterface) Disable()
func (*TCPServerInterface) Enable ¶
func (ts *TCPServerInterface) Enable()
func (*TCPServerInterface) GetName ¶
func (ts *TCPServerInterface) GetName() string
func (*TCPServerInterface) GetPacketCallback ¶
func (ts *TCPServerInterface) GetPacketCallback() common.PacketCallback
func (*TCPServerInterface) IsDetached ¶
func (ts *TCPServerInterface) IsDetached() bool
func (*TCPServerInterface) IsEnabled ¶
func (ts *TCPServerInterface) IsEnabled() bool
func (*TCPServerInterface) IsOnline ¶
func (ts *TCPServerInterface) IsOnline() bool
func (*TCPServerInterface) ProcessOutgoing ¶
func (ts *TCPServerInterface) ProcessOutgoing(data []byte) error
func (*TCPServerInterface) Send ¶ added in v0.9.0
func (ts *TCPServerInterface) Send(data []byte, address string) error
func (*TCPServerInterface) SetPacketCallback ¶
func (ts *TCPServerInterface) SetPacketCallback(callback common.PacketCallback)
func (*TCPServerInterface) Start ¶
func (ts *TCPServerInterface) Start() error
func (*TCPServerInterface) Stop ¶
func (ts *TCPServerInterface) Stop() error
func (*TCPServerInterface) String ¶
func (ts *TCPServerInterface) String() string
type UDPInterface ¶
type UDPInterface struct {
BaseInterface
// contains filtered or unexported fields
}
func NewUDPInterface ¶
func (*UDPInterface) Detach ¶
func (ui *UDPInterface) Detach()
func (*UDPInterface) Disable ¶
func (ui *UDPInterface) Disable()
func (*UDPInterface) Enable ¶
func (ui *UDPInterface) Enable()
func (*UDPInterface) GetBitrate ¶
func (ui *UDPInterface) GetBitrate() int
func (*UDPInterface) GetConn ¶
func (ui *UDPInterface) GetConn() net.Conn
func (*UDPInterface) GetMTU ¶
func (ui *UDPInterface) GetMTU() int
func (*UDPInterface) GetMode ¶
func (ui *UDPInterface) GetMode() common.InterfaceMode
func (*UDPInterface) GetName ¶
func (ui *UDPInterface) GetName() string
func (*UDPInterface) GetPacketCallback ¶
func (ui *UDPInterface) GetPacketCallback() common.PacketCallback
func (*UDPInterface) GetRxBytes ¶
func (ui *UDPInterface) GetRxBytes() uint64
func (*UDPInterface) GetTxBytes ¶
func (ui *UDPInterface) GetTxBytes() uint64
func (*UDPInterface) GetType ¶
func (ui *UDPInterface) GetType() common.InterfaceType
func (*UDPInterface) IsDetached ¶
func (ui *UDPInterface) IsDetached() bool
func (*UDPInterface) IsEnabled ¶
func (ui *UDPInterface) IsEnabled() bool
func (*UDPInterface) IsOnline ¶
func (ui *UDPInterface) IsOnline() bool
func (*UDPInterface) ProcessIncoming ¶
func (ui *UDPInterface) ProcessIncoming(data []byte)
func (*UDPInterface) ProcessOutgoing ¶
func (ui *UDPInterface) ProcessOutgoing(data []byte) error
func (*UDPInterface) SetPacketCallback ¶
func (ui *UDPInterface) SetPacketCallback(callback common.PacketCallback)
func (*UDPInterface) Start ¶
func (ui *UDPInterface) Start() error
func (*UDPInterface) Stop ¶ added in v0.9.0
func (ui *UDPInterface) Stop() error
type WebSocketInterface ¶ added in v0.9.0
type WebSocketInterface struct {
BaseInterface
// contains filtered or unexported fields
}
func NewWebSocketInterface ¶ added in v0.9.0
func NewWebSocketInterface(name string, wsURL string, enabled bool) (*WebSocketInterface, error)
func (*WebSocketInterface) Detach ¶ added in v0.9.0
func (wsi *WebSocketInterface) Detach()
func (*WebSocketInterface) Disable ¶ added in v0.9.0
func (wsi *WebSocketInterface) Disable()
func (*WebSocketInterface) Enable ¶ added in v0.9.0
func (wsi *WebSocketInterface) Enable()
func (*WebSocketInterface) GetBandwidthAvailable ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetBandwidthAvailable() bool
func (*WebSocketInterface) GetConn ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetConn() net.Conn
func (*WebSocketInterface) GetMTU ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetMTU() int
func (*WebSocketInterface) GetMode ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetMode() common.InterfaceMode
func (*WebSocketInterface) GetName ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetName() string
func (*WebSocketInterface) GetType ¶ added in v0.9.0
func (wsi *WebSocketInterface) GetType() common.InterfaceType
func (*WebSocketInterface) IsDetached ¶ added in v0.9.0
func (wsi *WebSocketInterface) IsDetached() bool
func (*WebSocketInterface) IsEnabled ¶ added in v0.9.0
func (wsi *WebSocketInterface) IsEnabled() bool
func (*WebSocketInterface) IsOnline ¶ added in v0.9.0
func (wsi *WebSocketInterface) IsOnline() bool
func (*WebSocketInterface) ProcessOutgoing ¶ added in v0.9.0
func (wsi *WebSocketInterface) ProcessOutgoing(data []byte) error
func (*WebSocketInterface) Send ¶ added in v0.9.0
func (wsi *WebSocketInterface) Send(data []byte, addr string) error
func (*WebSocketInterface) SendLinkPacket ¶ added in v0.9.0
func (*WebSocketInterface) SendPathRequest ¶ added in v0.9.0
func (wsi *WebSocketInterface) SendPathRequest(packet []byte) error
func (*WebSocketInterface) Start ¶ added in v0.9.0
func (wsi *WebSocketInterface) Start() error
func (*WebSocketInterface) Stop ¶ added in v0.9.0
func (wsi *WebSocketInterface) Stop() error