nspkt

package
v0.0.0-...-668ff25 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package nspkt interacts with Northstar servers using connectionless packets.

Index

Constants

This section is empty.

Variables

View Source
var ErrListenerClosed = errors.New("listener closed")

Functions

func DebugMonitorHandler

func DebugMonitorHandler(l *Listener) http.Handler

DebugMonitorHandler returns a HTTP handler which serves a webpage to monitor sent and received connectionless packets in real-time.

Types

type Listener

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

Listener sends and receives Northstar connectionless packets over a UDP socket.

func NewListener

func NewListener() *Listener

NewListener creates a new listener.

func (*Listener) Close

func (l *Listener) Close()

Close immediately closes the active socket, if any, and unbinds it from the Listener, then waits for Serve to return.

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe(addr netip.AddrPort) error

ListenAndServe creates new UDP socket on addr and calls Listener.Serve.

func (*Listener) LocalAddr

func (l *Listener) LocalAddr() net.Addr

LocalAddr gets the local address of the active socket, if any.

func (*Listener) Monitor

func (l *Listener) Monitor(ctx context.Context, c chan<- MonitorPacket)

Monitor writes unencrypted sent/received packets to c until ctx is cancelled, discarding them if c doesn't have room.

func (*Listener) SendAtlasSigreq1

func (l *Listener) SendAtlasSigreq1(addr netip.AddrPort, key string, obj any) error

SendAtlasSigreq1 sends a signed Atlas JSON request.

func (*Listener) SendAtlasSigreq1Raw

func (l *Listener) SendAtlasSigreq1Raw(addr netip.AddrPort, key, data []byte) error

SendAtlasSigreq1Raw sends a raw `Tsigreq1` packet.

func (*Listener) SendConnect

func (l *Listener) SendConnect(addr netip.AddrPort, uid uint64) error

SendConnect sends a `Hconnect` packet to addr for uid.

func (*Listener) Serve

func (l *Listener) Serve(conn *net.UDPConn) error

Serve binds the listener to conn, which should not be used afterwards. If l is already bound, the existing conn will be closed and replaced.

func (*Listener) WaitConnectReply

func (l *Listener) WaitConnectReply(ctx context.Context, addr netip.AddrPort, uid uint64) error

WaitConnectReply waits for a reply to `Hconnect` from addr with uid.

func (*Listener) WritePrometheus

func (l *Listener) WritePrometheus(w io.Writer)

WritePrometheus writes prometheus text metrics to w.

type MonitorPacket

type MonitorPacket struct {
	In     bool
	Remote netip.AddrPort
	Desc   string
	Data   []byte
}

MonitorPacket describes a sent/received unencrypted connectionless packet.

Jump to

Keyboard shortcuts

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