Documentation ¶
Index ¶
- Variables
- type AnnouncePingAttachment
- type AnnouncePingHandler
- type AnnouncePingMsg
- type Config
- type DisconnectPingHandler
- func (h *DisconnectPingHandler) Clean(w *mgr.WorkerCtx) error
- func (h *DisconnectPingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
- func (h *DisconnectPingHandler) Send(goingDown bool, disconnected []netip.Addr) error
- func (h *DisconnectPingHandler) Type() string
- type DisconnectPingMsg
- type ErrorPingHandler
- func (h *ErrorPingHandler) Clean(w *mgr.WorkerCtx) error
- func (h *ErrorPingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
- func (h *ErrorPingHandler) SendAccessDenied(to netip.Addr, dstIP netip.Addr, protocol uint8, dstPort uint16) error
- func (h *ErrorPingHandler) SendGeneric(to netip.Addr, text string) error
- func (h *ErrorPingHandler) SendNoEncryptionKeys(to netip.Addr) error
- func (h *ErrorPingHandler) SendRejected(to netip.Addr, dstIP netip.Addr, protocol uint8, dstPort uint16) error
- func (h *ErrorPingHandler) SendUnreachable(to, unreachable netip.Addr) error
- func (h *ErrorPingHandler) Type() string
- type ExportedConnection
- type HelloPingHandler
- type HelloPingRequest
- type HelloPingResponse
- type PingHandler
- type PingHeader
- type PingPongHandler
- func (h *PingPongHandler) Clean(w *mgr.WorkerCtx) error
- func (h *PingPongHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
- func (h *PingPongHandler) Send(dstIP netip.Addr, peer bool, retryPingID uint64) (notify <-chan struct{}, pingID uint64, err error)
- func (h *PingPongHandler) Type() string
- type Router
- func (r *Router) ExportConnections(maxAge time.Duration) []ExportedConnection
- func (r *Router) GetPingHandler(pingType string) PingHandler
- func (r *Router) Input() chan frame.Frame
- func (r *Router) RegisterPingHandler(handler PingHandler) error
- func (r *Router) RouteFrame(f frame.Frame) error
- func (r *Router) Start(mgr *mgr.Manager) error
- func (r *Router) Stop(mgr *mgr.Manager) error
- func (r *Router) Table() *m.RoutingTable
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWouldLoop is returned when a packet cannot be routed because it would // be sent back where it was received from. ErrWouldLoop = errors.New("not routing: would loop") // ErrTableEmpty is returned when a packet cannot be routed because the // routing table is empty. ErrTableEmpty = errors.New("not routing: table empty") )
var (
ErrAlreadyActive = errors.New("already active")
)
Errors.
Functions ¶
This section is empty.
Types ¶
type AnnouncePingAttachment ¶
type AnnouncePingAttachment struct { Router m.PublicAddress `cbor:"r" json:"r"` Delay uint16 `cbor:"d,omitempty" json:"d,omitempty"` ForwardLabel m.SwitchLabel `cbor:"f,omitempty" json:"f,omitempty"` ReturnLabel m.SwitchLabel `cbor:"b,omitempty" json:"b,omitempty"` NextAttachment []byte `cbor:"n,omitempty" json:"n,omitempty"` }
AnnouncePingAttachment is an announce ping attachment.
type AnnouncePingHandler ¶
type AnnouncePingHandler struct {
// contains filtered or unexported fields
}
AnnouncePingHandler handles announce pings.
func NewAnnouncePingHandler ¶
func NewAnnouncePingHandler(r *Router) *AnnouncePingHandler
NewAnnouncePingHandler returns a new announce ping handler.
func (*AnnouncePingHandler) Clean ¶
func (h *AnnouncePingHandler) Clean(w *mgr.WorkerCtx) error
Clean cleans any internal state of the ping handler.
func (*AnnouncePingHandler) Handle ¶
func (h *AnnouncePingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
Handle handles incoming ping frames.
func (*AnnouncePingHandler) Send ¶
func (h *AnnouncePingHandler) Send(peer netip.Addr) error
Send sends a hello message to the given destination.
func (*AnnouncePingHandler) Type ¶
func (h *AnnouncePingHandler) Type() string
Type returns the ping type.
type AnnouncePingMsg ¶
type AnnouncePingMsg struct { Info *m.RouterInfo `cbor:"i,omitempty" json:"i,omitempty"` ReturnLabel m.SwitchLabel `cbor:"b,omitempty" json:"b,omitempty"` Expires time.Time `cbor:"e,omitempty" json:"e,omitempty"` }
AnnouncePingMsg is an announce ping message.
type DisconnectPingHandler ¶ added in v0.4.0
type DisconnectPingHandler struct {
// contains filtered or unexported fields
}
DisconnectPingHandler handles announce pings.
func NewDisconnectPingHandler ¶ added in v0.4.0
func NewDisconnectPingHandler(r *Router) *DisconnectPingHandler
NewDisconnectPingHandler returns a new announce ping handler.
func (*DisconnectPingHandler) Clean ¶ added in v0.4.0
func (h *DisconnectPingHandler) Clean(w *mgr.WorkerCtx) error
Clean cleans any internal state of the ping handler.
func (*DisconnectPingHandler) Handle ¶ added in v0.4.0
func (h *DisconnectPingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
Handle handles incoming ping frames.
func (*DisconnectPingHandler) Send ¶ added in v0.4.0
func (h *DisconnectPingHandler) Send(goingDown bool, disconnected []netip.Addr) error
Send sends a hello message to the given destination.
func (*DisconnectPingHandler) Type ¶ added in v0.4.0
func (h *DisconnectPingHandler) Type() string
Type returns the ping type.
type DisconnectPingMsg ¶ added in v0.4.0
type DisconnectPingMsg struct { // GoingDown signifies that the router is about to go offline. GoingDown bool `cbor:"off,omitempty" json:"off,omitempty"` // Disconnected holds a list of routers that are no longer connected to the announcing router. // Ignored when GoingDown is set. Disconnected []netip.Addr `cbor:"d,omitempty" json:"d,omitempty"` }
DisconnectPingMsg is a disconnect ping message.
type ErrorPingHandler ¶ added in v0.1.0
type ErrorPingHandler struct {
// contains filtered or unexported fields
}
ErrorPingHandler handles announce pings.
func NewErrorPingHandler ¶ added in v0.1.0
func NewErrorPingHandler(r *Router) *ErrorPingHandler
NewErrorPingHandler returns a new announce ping handler.
func (*ErrorPingHandler) Clean ¶ added in v0.1.0
func (h *ErrorPingHandler) Clean(w *mgr.WorkerCtx) error
Clean cleans any internal state of the ping handler.
func (*ErrorPingHandler) Handle ¶ added in v0.1.0
func (h *ErrorPingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
Handle handles incoming ping frames.
func (*ErrorPingHandler) SendAccessDenied ¶ added in v0.4.0
func (h *ErrorPingHandler) SendAccessDenied(to netip.Addr, dstIP netip.Addr, protocol uint8, dstPort uint16) error
SendAccessDenied sends an access denied error.
func (*ErrorPingHandler) SendGeneric ¶ added in v0.4.0
func (h *ErrorPingHandler) SendGeneric(to netip.Addr, text string) error
SendGeneric sends a generic error.
func (*ErrorPingHandler) SendNoEncryptionKeys ¶ added in v0.4.0
func (h *ErrorPingHandler) SendNoEncryptionKeys(to netip.Addr) error
SendNoEncryptionKeys sends a "no encryption keys" error.
func (*ErrorPingHandler) SendRejected ¶ added in v0.4.0
func (h *ErrorPingHandler) SendRejected(to netip.Addr, dstIP netip.Addr, protocol uint8, dstPort uint16) error
SendRejected sends a rejected error.
func (*ErrorPingHandler) SendUnreachable ¶ added in v0.4.0
func (h *ErrorPingHandler) SendUnreachable(to, unreachable netip.Addr) error
SendUnreachable sends an unreachable error.
func (*ErrorPingHandler) Type ¶ added in v0.1.0
func (h *ErrorPingHandler) Type() string
Type returns the ping type.
type ExportedConnection ¶ added in v0.4.0
type ExportedConnection struct { LocalIP netip.Addr RemoteIP netip.Addr Protocol uint8 LocalPort uint16 RemotePort uint16 Inbound bool StatusName string StatusColor string FirstSeen time.Time LastSeen time.Time DataIn uint64 DataOut uint64 }
ExportedConnection is an exported version of a connection.
func (*ExportedConnection) HasPorts ¶ added in v0.4.0
func (e *ExportedConnection) HasPorts() bool
HasPorts returns whether the connection has ports.
func (*ExportedConnection) ProtocolName ¶ added in v0.4.0
func (e *ExportedConnection) ProtocolName() string
ProtocolName returns the protocol name, if available. Otherwise a string representation of the protocol number is returned.
func (*ExportedConnection) TimeDescription ¶ added in v0.4.0
func (e *ExportedConnection) TimeDescription() string
TimeDescription returns a simplified and readable description of the first and last seen timestamps.
type HelloPingHandler ¶
type HelloPingHandler struct {
// contains filtered or unexported fields
}
HelloPingHandler handles hello pings.
func NewHelloPingHandler ¶
func NewHelloPingHandler(r *Router) *HelloPingHandler
NewHelloPingHandler returns a new hello ping handler.
func (*HelloPingHandler) Clean ¶
func (h *HelloPingHandler) Clean(w *mgr.WorkerCtx) error
Clean cleans any internal state of the ping handler.
func (*HelloPingHandler) Handle ¶
func (h *HelloPingHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
Handle handles incoming ping frames.
func (*HelloPingHandler) Send ¶
func (h *HelloPingHandler) Send(dstIP netip.Addr) (notify <-chan struct{}, err error)
Send sends a hello message to the given destination.
func (*HelloPingHandler) Type ¶
func (h *HelloPingHandler) Type() string
Type returns the ping type.
type HelloPingRequest ¶
type HelloPingRequest struct { KeyExchange []byte `cbor:"kx,omitempty" json:"kx,omitempty"` KeyExchangeType string `cbor:"kxt,omitempty" json:"kxt,omitempty"` MTU int `cbor:"mtu,omitempty" json:"mtu,omitempty"` }
HelloPingRequest is a hello ping request.
type HelloPingResponse ¶
type HelloPingResponse struct { KeyExchange []byte `cbor:"kx,omitempty" json:"kx,omitempty"` KeyExchangeType string `cbor:"kxt,omitempty" json:"kxt,omitempty"` MTU int `cbor:"mtu,omitempty" json:"mtu,omitempty"` Err string `cbor:"err,omitempty" json:"err,omitempty"` }
HelloPingResponse is a hello ping response.
type PingHandler ¶
type PingHandler interface { Type() string Handle(w *mgr.WorkerCtx, f frame.Frame, pingHdr *PingHeader, pingData []byte) error Clean(w *mgr.WorkerCtx) error }
PingHandler handles ping messages of a type.
type PingHeader ¶
type PingHeader struct { PingID uint64 `cbor:"i,omitempty" json:"i,omitempty"` PingType string `cbor:"t,omitempty" json:"t,omitempty"` PingCode uint8 `cbor:"c,omitempty" json:"c,omitempty"` FollowUp bool `cbor:"f,omitempty" json:"f,omitempty"` AddrHash m.Hash `cbor:"h,omitempty" json:"h,omitempty"` KeyType string `cbor:"a,omitempty" json:"a,omitempty"` PublicKey ed25519.PublicKey `cbor:"k,omitempty" json:"k,omitempty"` }
PingHeader is the header used for every ping message.
type PingPongHandler ¶
type PingPongHandler struct {
// contains filtered or unexported fields
}
PingPongHandler handles pong pings.
func NewPingPongHandler ¶
func NewPingPongHandler(r *Router) *PingPongHandler
NewPingPongHandler returns a new pong ping handler.
func (*PingPongHandler) Clean ¶
func (h *PingPongHandler) Clean(w *mgr.WorkerCtx) error
Clean cleans any internal state of the ping handler.
func (*PingPongHandler) Handle ¶
func (h *PingPongHandler) Handle(w *mgr.WorkerCtx, f frame.Frame, hdr *PingHeader, data []byte) error
Handle handles incoming ping frames.
type Router ¶
type Router struct { HelloPing *HelloPingHandler PingPong *PingPongHandler ErrorPing *ErrorPingHandler AnnouncePing *AnnouncePingHandler DisconnectPing *DisconnectPingHandler // contains filtered or unexported fields }
Router is the primary handler for frames.
func (*Router) ExportConnections ¶ added in v0.4.0
func (r *Router) ExportConnections(maxAge time.Duration) []ExportedConnection
ExportConnections returns an exported version of the connections.
func (*Router) GetPingHandler ¶
func (r *Router) GetPingHandler(pingType string) PingHandler
GetPingHandler returns the ping handler of the given ping type.
func (*Router) RegisterPingHandler ¶
func (r *Router) RegisterPingHandler(handler PingHandler) error
RegisterPingHandler registers the given ping handler in the router.
func (*Router) RouteFrame ¶
RouteFrame forwards the given frame to the next hop based on the destination IP.