Documentation
¶
Index ¶
- func Resp[T any](c fiber.Ctx, httpCode int, statusCode int, data T, msg string) error
- func RespInternalServerError(c fiber.Ctx, err error) error
- func RespNotFound(c fiber.Ctx) error
- func RespSuccess[T any](c fiber.Ctx, data T) error
- type Counters
- func (c *Counters) AddReceivedBytes(n uint64)
- func (c *Counters) AddReceivedDups(n uint64)
- func (c *Counters) AddReceivedErrors(n uint64)
- func (c *Counters) AddReceivedPackets(n uint64)
- func (c *Counters) AddReceivedQDrop(n uint64)
- func (c *Counters) AddSentBytes(n uint64)
- func (c *Counters) AddSentPackets(n uint64)
- func (c *Counters) Snapshot() Statistics
- func (c *Counters) UpdateRates()
- type ListenerConfig
- type Memory
- type ReturnClient
- type ReturnClientList
- type ReturnListener
- type ReturnPeer
- type ReturnServer
- type ReturnStatus
- type ReturnTotals
- type ReturnUplink
- type Statistics
- type StatsReturn
- type SystemStatus
- type UplinkConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RespNotFound ¶
Types ¶
type Counters ¶
type Counters struct {
// contains filtered or unexported fields
}
Counters holds the concurrently-updated cumulative statistics for a client, listener, server or the global aggregate. The cumulative totals are atomic so they can be incremented from many goroutines without locking. The derived per-second rates are computed by a single updater goroutine and stored in plain fields; readers obtain a consistent view via Snapshot.
func (*Counters) AddReceivedBytes ¶
AddReceivedBytes atomically adds to the received-byte total.
func (*Counters) AddReceivedDups ¶
AddReceivedDups atomically adds to the duplicate total.
func (*Counters) AddReceivedErrors ¶
AddReceivedErrors atomically adds to the error total.
func (*Counters) AddReceivedPackets ¶
AddReceivedPackets atomically adds to the received-packet total.
func (*Counters) AddReceivedQDrop ¶
AddReceivedQDrop atomically adds to the q-drop total.
func (*Counters) AddSentBytes ¶
AddSentBytes atomically adds to the sent-byte total.
func (*Counters) AddSentPackets ¶
AddSentPackets atomically adds to the sent-packet total.
func (*Counters) Snapshot ¶
func (c *Counters) Snapshot() Statistics
Snapshot returns a plain-value copy of the current statistics suitable for JSON serialisation and display.
func (*Counters) UpdateRates ¶
func (c *Counters) UpdateRates()
UpdateRates recomputes the per-second rates from the cumulative totals. It must be called by a single goroutine (e.g. a 1s ticker).
type ListenerConfig ¶
type ListenerConfig struct {
Name string `json:"name" yaml:"name"`
Mode string `json:"mode" yaml:"mode"`
Protocol string `json:"protocol" yaml:"protocol"`
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Visible string `json:"visible" yaml:"visible"`
Filter string `json:"filter" yaml:"filter"`
}
ListenerConfig provides a struct to load listeners from config
type Memory ¶
type Memory struct {
Total float64 `json:"total"`
Used float64 `json:"used"`
Self float64 `json:"self"`
TotalAllocated float64 `json:"total_allocated"`
CurrentAllocated float64 `json:"current_allocated"`
Malloc uint64 `json:"malloc"`
Free uint64 `json:"free"`
Heap float64 `json:"heap"`
NumGC uint32 `json:"num_gc"`
PauseTotalSec float64 `json:"pause_total_sec"`
LastGC time.Time `json:"last_gc"`
LastPauseTotalSec float64 `json:"last_pause_total_sec"`
NextGC float64 `json:"next_gc"`
Lookups uint64 `json:"lookups"`
}
Memory provides a basic struct to describe memory status
type ReturnClient ¶
type ReturnClient struct {
At string `json:"at"`
Port int `json:"port"`
ID string `json:"id"`
Verified bool `json:"verified"`
Addr string `json:"addr"`
Uptime time.Time `json:"uptime"`
Last time.Time `json:"last"` // last received from the client
LastTX time.Time `json:"last_tx"` // last sent to the client
Software string `json:"software"`
Version string `json:"version"`
Filter string `json:"filter"`
OutQ int `json:"out_q"` // bytes queued for delivery
MsgRcpts int `json:"msg_rcpts"` // text messages delivered to this client
PacketRX uint64 `json:"packet_rx"`
PacketRXDup uint64 `json:"packet_rx_dup"`
PacketRXErr uint64 `json:"packet_rx_err"`
PacketRXRate uint64 `json:"packet_rx_rate"`
PacketTX uint64 `json:"packet_tx"`
PacketTXRate uint64 `json:"packet_tx_rate"`
BytesRX uint64 `json:"bytes_rx"`
BytesRXRate uint64 `json:"bytes_rx_rate"`
BytesTX uint64 `json:"bytes_tx"`
BytesTXRate uint64 `json:"bytes_tx_rate"`
}
ReturnClient provides a struct to return client info
type ReturnClientList ¶ added in v1.3.0
type ReturnClientList struct {
Total int `json:"total"` // clients across all pages
Page int `json:"page"` // 1-based page number
PageSize int `json:"page_size"` // rows per page
Clients []*ReturnClient `json:"clients"`
}
ReturnClientList is one page of the connected-client list, in a stable caller-requested order.
type ReturnListener ¶
type ReturnListener struct {
Name string `json:"name"`
Mode string `json:"mode"`
Protocol string `json:"protocol"`
Host string `json:"host"`
Port int `json:"port"`
Filter string `json:"filter"`
OnlineClient int `json:"online_client"`
PeakClient int `json:"peak_client"`
PacketRX uint64 `json:"packet_rx"`
PacketRXRate uint64 `json:"packet_rx_rate"`
PacketTX uint64 `json:"packet_tx"`
PacketTXRate uint64 `json:"packet_tx_rate"`
BytesRX uint64 `json:"bytes_rx"`
BytesRXRate uint64 `json:"bytes_rx_rate"`
BytesTX uint64 `json:"bytes_tx"`
BytesTXRate uint64 `json:"bytes_tx_rate"`
}
ReturnListener provides a struct to return listener info
type ReturnPeer ¶
type ReturnPeer struct {
Name string `json:"name"`
ID string `json:"id"`
Addr string `json:"addr"`
}
ReturnPeer is core-peer info. A peer is a symmetric two-way server link.
type ReturnServer ¶
type ReturnServer struct {
Admin string `json:"admin"`
Email string `json:"email"`
OS string `json:"os"`
Arch string `json:"arch"`
ID string `json:"id"`
Software string `json:"software"` // program name, e.g. "APRSGo"
Codename string `json:"codename"` // release codename, e.g. "Ampere"
Version string `json:"version"` // numeric version, e.g. "1.0.0"
Now time.Time `json:"now"`
Uptime float64 `json:"uptime"`
Model string `json:"model"`
Percent float64 `json:"percent"`
Memory Memory `json:"memory"`
}
ReturnServer provides a struct to return basic server info
type ReturnStatus ¶
type ReturnStatus struct {
Server ReturnServer `json:"server"`
Totals ReturnTotals `json:"totals"`
Uplink *ReturnUplink `json:"uplink"`
Peers []*ReturnPeer `json:"peers"`
Listeners []*ReturnListener `json:"listeners"`
}
ReturnStatus provides a struct to return status of server. The connected client list is intentionally not part of this payload: it can be large, so it is served paginated by GET /api/clients instead.
type ReturnTotals ¶
type ReturnTotals struct {
// Connected client count and process uptime context.
Clients int `json:"clients"`
// Cumulative packet/byte counters across all inbound ports.
PacketRX uint64 `json:"packet_rx"`
PacketTX uint64 `json:"packet_tx"`
BytesRX uint64 `json:"bytes_rx"`
BytesTX uint64 `json:"bytes_tx"`
// Per-second rates.
PacketRXRate uint64 `json:"packet_rx_rate"`
PacketTXRate uint64 `json:"packet_tx_rate"`
BytesRXRate uint64 `json:"bytes_rx_rate"`
BytesTXRate uint64 `json:"bytes_tx_rate"`
// Duplicate packets dropped.
Dupes uint64 `json:"dupes"`
// Station position-cache and message-routing sizes.
PositionCache int `json:"position_cache"`
}
ReturnTotals aggregates process-wide counters for the status page.
type ReturnUplink ¶
type ReturnUplink struct {
ID string `json:"id"`
Mode client.Mode `json:"mode"`
Protocol client.Protocol `json:"protocol"`
Host string `json:"host"` // configured hostname
RealAddr string `json:"real_addr"` // resolved remote IP:port
Port int `json:"port"`
ServerID string `json:"server_id"` // upstream server callsign
Server string `json:"server"` // upstream software banner
Up bool `json:"up"`
Uptime time.Time `json:"uptime"`
Last time.Time `json:"last"`
PacketRX uint64 `json:"packet_rx"`
PacketRXDup uint64 `json:"packet_rx_dup"`
PacketRXErr uint64 `json:"packet_rx_err"`
PacketRXRate uint64 `json:"packet_rx_rate"`
PacketTX uint64 `json:"packet_tx"`
PacketTXRate uint64 `json:"packet_tx_rate"`
BytesRX uint64 `json:"bytes_rx"`
BytesRXRate uint64 `json:"bytes_rx_rate"`
BytesTX uint64 `json:"bytes_tx"`
BytesTXRate uint64 `json:"bytes_tx_rate"`
}
ReturnUplink is uplink info. An uplink is a one-way link to an upstream server (this server is the child).
type Statistics ¶
type Statistics struct {
SentPackets uint64 `json:"sent_packets"`
ReceivedPackets uint64 `json:"received_packets"`
ReceivedDups uint64 `json:"received_dups"`
ReceivedErrors uint64 `json:"received_errors"`
ReceivedQDrop uint64 `json:"received_q_drop"`
SentBytes uint64 `json:"sent_bytes"`
ReceivedBytes uint64 `json:"received_bytes"`
// Rates (packets per second)
SendPacketRate uint64 `json:"send_packet_rate"`
RecvPacketRate uint64 `json:"recv_packet_rate"`
SendByteRate uint64 `json:"send_byte_rate"`
RecvByteRate uint64 `json:"recv_byte_rate"`
}
Statistics holds all statistics data
type StatsReturn ¶
type StatsReturn struct {
Memory [][2]any `json:"memory"`
UplinkPacketRX [][2]any `json:"uplink_packet_rx"`
UplinkPacketTX [][2]any `json:"uplink_packet_tx"`
UplinkBytesRX [][2]any `json:"uplink_bytes_rx"`
UplinkBytesTX [][2]any `json:"uplink_bytes_tx"`
}
StatsReturn provides a struct to return stats of server
type SystemStatus ¶
SystemStatus provides the struct to store the basic system status
type UplinkConfig ¶
type UplinkConfig struct {
Name string `json:"name" yaml:"name"`
Mode client.Mode `json:"mode" yaml:"mode"`
Protocol client.Protocol `json:"protocol" yaml:"protocol"`
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
}
UplinkConfig provides a struct to load uplinks from config