opnsense

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const HealthCheckStatusOK = "OK"
View Source
const MaxRetries = 3

MaxRetries is the maximum number of retries when a request to the OPNsense API fails

Variables

This section is empty.

Functions

This section is empty.

Types

type APICallError

type APICallError struct {
	Endpoint   string
	StatusCode int
	Message    string
}

APICallError is an error returned by the OPNsense API

func (APICallError) Error

func (e APICallError) Error() string

type Arp

type Arp struct {
	Mac             string
	IP              string
	Expired         bool
	Expires         int
	Permanent       bool
	Type            string
	Hostname        string
	IntfDescription string
}

type ArpTable

type ArpTable struct {
	TotalEntries int
	Arp          []Arp
}

type Client

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

Client is an OPNsense API client

func NewClient

func NewClient(cfg options.OPNSenseConfig, userAgentVersion string, log log.Logger) (Client, error)

NewClient creates a new OPNsense API Client

func (*Client) Endpoints

func (c *Client) Endpoints() map[EndpointName]EndpointPath

Endpoints returns a map of all the endpoints that are called by the client.

func (*Client) FetchArpTable

func (c *Client) FetchArpTable() (ArpTable, *APICallError)

func (*Client) FetchCronTable

func (c *Client) FetchCronTable() (CronTable, *APICallError)

func (*Client) FetchGateways

func (c *Client) FetchGateways() (Gateways, *APICallError)

FetchGateways fetches the gateways status details from the OPNsense API and returns a safe wrapper Gateways struct.

func (*Client) FetchInterfaces

func (c *Client) FetchInterfaces() (Interfaces, *APICallError)

func (*Client) FetchOpenVPNInstances

func (c *Client) FetchOpenVPNInstances() (OpenVPNInstances, *APICallError)

func (*Client) FetchProtocolStatistics

func (c *Client) FetchProtocolStatistics() (ProtocolStatistics, *APICallError)

func (*Client) FetchServices

func (c *Client) FetchServices() (Services, *APICallError)

func (*Client) FetchSystemInfo

func (c *Client) FetchSystemInfo() (SystemInfo, *APICallError)

func (*Client) FetchUnboundOverview

func (c *Client) FetchUnboundOverview() (UnboundDNSOverview, *APICallError)

func (*Client) FetchWireguardConfig

func (c *Client) FetchWireguardConfig() (WireguardClients, *APICallError)

func (*Client) HealthCheck

func (c *Client) HealthCheck() (HealthCheckResponse, error)

HealthCheck checks if the OPNsense is up and running.

type Cron

type Cron struct {
	UUID        string
	Status      CronStatus
	Schedule    string
	Description string
	Command     string
	Origin      string
}

type CronStatus

type CronStatus int
const (
	CronStatusDisabled CronStatus = iota
	CronStatusEnabled
)

type CronTable

type CronTable struct {
	TotalEntries int
	Cron         []Cron
}

type EndpointName

type EndpointName string

EndpointName is the custom type for name of an endpoint definition

type EndpointPath

type EndpointPath string

EndpointPath is the custom type for url path of an endpoint definition

type Gateway

type Gateway struct {
	Name             string
	Address          string
	Status           GatewayStatus
	RTTMilliseconds  float64
	RTTDMilliseconds float64
	LossPercentage   float64
}

type GatewayStatus

type GatewayStatus int

GatewayStatus is the custom type that represents the status of a gateway

const (
	GatewayStatusOffline GatewayStatus = iota
	GatewayStatusOnline
	GatewayStatusUnknown
)

type Gateways

type Gateways struct {
	Gateways []Gateway
}

type HealthCheckResponse

type HealthCheckResponse struct {
	CrashReporter struct {
		StatusCode  int    `json:"statusCode"`
		Message     string `json:"message"`
		LogLocation string `json:"logLocation"`
		Timestamp   string `json:"timestamp"`
		Status      string `json:"status"`
	} `json:"CrashReporter"`
	Firewall struct {
		StatusCode  int    `json:"statusCode"`
		Message     string `json:"message"`
		LogLocation string `json:"logLocation"`
		Timestamp   string `json:"timestamp"`
		Status      string `json:"status"`
	} `json:"Firewall"`
	System struct {
		Status string `json:"status"`
	} `json:"System"`
}

type Interface

type Interface struct {
	Name                  string
	Device                string
	Type                  string
	MTU                   int
	PacketsReceived       int
	PacketsTransmitted    int
	BytesReceived         int
	BytesTransmitted      int
	MulticastsReceived    int
	MulticastsTransmitted int
	InputErrors           int
	OutputErrors          int
	Collisions            int
}

type InterfaceDetails

type InterfaceDetails struct {
	Device                    string `json:"device"`
	Driver                    string `json:"driver"`
	Index                     string `json:"index"`
	Flags                     string `json:"flags"`
	PromiscuousListeners      string `json:"promiscuous listeners"`
	SendQueueLength           string `json:"send queue length"`
	SendQueueMaxLength        string `json:"send queue max length"`
	SendQueueDrops            string `json:"send queue drops"`
	Type                      string `json:"type"`
	AddressLength             string `json:"address length"`
	HeaderLength              string `json:"header length"`
	LinkState                 string `json:"link state"`
	Vhid                      string `json:"vhid"`
	Datalen                   string `json:"datalen"`
	MTU                       string `json:"mtu"`
	Metric                    string `json:"metric"`
	LineRate                  string `json:"line rate"`
	PacketsReceived           string `json:"packets received"`
	PacketsTransmitted        string `json:"packets transmitted"`
	BytesReceived             string `json:"bytes received"`
	BytesTransmitted          string `json:"bytes transmitted"`
	OutputErrors              string `json:"output errors"`
	InputErrors               string `json:"input errors"`
	Collisions                string `json:"collisions"`
	MulticastsReceived        string `json:"multicasts received"`
	MulticastsTransmitted     string `json:"multicasts transmitted"`
	InputQueueDrops           string `json:"input queue drops"`
	PacketsForUnknownProtocol string `json:"packets for unknown protocol"`
	HWOffloadCapabilities     string `json:"HW offload capabilities"`
	UptimeAtAttachOrStatReset string `json:"uptime at attach or stat reset"`
	Name                      string `json:"name"`
}

type Interfaces

type Interfaces struct {
	Interfaces []Interface
}

type OpenVPN

type OpenVPN struct {
	UUID        string
	Description string
	Role        string
	DevType     string
	Enabled     int
}

type OpenVPNInstances

type OpenVPNInstances struct {
	Rows []OpenVPN
}

type ProtocolStatistics

type ProtocolStatistics struct {
	TCPSentPackets            int
	TCPReceivedPackets        int
	ARPSentRequests           int
	ARPReceivedRequests       int
	TCPConnectionCountByState map[string]int
	ICMPCalls                 int
	ICMPSentPackets           int
	ICMPDroppedByReason       map[string]int
	UDPDeliveredPackets       int
	UDPOutputPackets          int
	UDPReceivedDatagrams      int
	UDPDroppedByReason        map[string]int
}

type Service

type Service struct {
	Status      ServiceStatus
	Description string
	Name        string
}

type ServiceStatus

type ServiceStatus int
const (
	ServiceStatusStopped ServiceStatus = iota
	ServiceStatusRunning
	ServiceStatusUnknown
)

type Services

type Services struct {
	TotalRunning int
	TotalStopped int
	Services     []Service
}

type SystemInfo

type SystemInfo struct {
	Temperature []Temperature
}

type Temperature

type Temperature struct {
	Device                string
	DeviceSeq             string
	Type                  string
	TemperatureCelsuis    int
	TemperatureFahrenheit float32
}

type UnboundDNSOverview

type UnboundDNSOverview struct {
	Total             int
	BlocklistSize     int
	Passed            int
	UptimeSeconds     float64
	AnswerRcodes      map[string]int
	AnswerRcodesTotal int
	AnnswerBogusTotal int
	AnswerSecureTotal int
	QueryTypes        map[string]int
}

type WGInterfaceStatus

type WGInterfaceStatus int

WGInterfaceStatus is the custom type that represents the status of a Wireguard interface

const (
	WGInterfaceStatusDown WGInterfaceStatus = iota
	WGInterfaceStatusUp
	WGInterfaceStatusUnknown
)

type WireguardClients

type WireguardClients struct {
	Peers      []WireguardPeers
	Interfaces []WireguardInterfaces
}

type WireguardInterfaces

type WireguardInterfaces struct {
	Device     string
	DeviceType string
	Status     WGInterfaceStatus
	Name       string
	DeviceName string
}

type WireguardPeers

type WireguardPeers struct {
	Device          string
	DeviceName      string
	DeviceType      string
	LatestHandshake float64
	TransferRx      float64
	TransferTx      float64
	Name            string
}

Jump to

Keyboard shortcuts

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