api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Status   string          `json:"status,omitempty"`
	Result   string          `json:"result,omitempty"`
	Message  string          `json:"message,omitempty"`
	UUID     string          `json:"uuid,omitempty"`
	Data     json.RawMessage `json:"data,omitempty"`
	Rows     json.RawMessage `json:"rows,omitempty"`
	RowCount int             `json:"rowCount,omitempty"`
	Total    int             `json:"total,omitempty"`
	Current  int             `json:"current,omitempty"`
}

APIResponse represents the response from the OPNSense API

type CaddyClient

type CaddyClient struct {
	ServerIP   string
	ServerPort int
}

CaddyClient handles communication with the Caddy server

func NewCaddyClient

func NewCaddyClient(serverIP string, serverPort int) *CaddyClient

NewCaddyClient creates a new Caddy client

func (*CaddyClient) ExtractHostnames

func (c *CaddyClient) ExtractHostnames(config map[string]interface{}) ([]string, error)

ExtractHostnames extracts all hostnames from the Caddy configuration

func (*CaddyClient) GetConfig

func (c *CaddyClient) GetConfig() (map[string]interface{}, error)

GetConfig fetches the Caddy server configuration

func (*CaddyClient) GetHostnameMap

func (c *CaddyClient) GetHostnameMap() (map[string]string, error)

GetHostnameMap returns a map of all hostnames in the Caddy configuration, with each hostname mapped to the server that should handle it

type Client

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

Client handles API communication with OPNSense

func NewClient

func NewClient(config Config) *Client

NewClient creates a new OPNSense API client

func (*Client) AddOverride

func (c *Client) AddOverride(override DNSOverride) (string, error)

AddOverride creates a new DNS override

func (*Client) ApplyChanges

func (c *Client) ApplyChanges() error

ApplyChanges applies all DNS changes to the Unbound service

func (*Client) DeleteOverride

func (c *Client) DeleteOverride(uuid string) error

DeleteOverride removes a DNS override

func (*Client) GetOverrides

func (c *Client) GetOverrides() ([]DNSOverride, error)

GetOverrides retrieves all DNS overrides

func (*Client) IsOverrideExists

func (c *Client) IsOverrideExists(host, domain string) (bool, string, error)

IsOverrideExists checks if a DNS override with the same host and domain already exists

func (*Client) UpdateOverride

func (c *Client) UpdateOverride(override DNSOverride) error

UpdateOverride updates an existing DNS override

type Config

type Config struct {
	APIKey    string `json:"api_key"    mapstructure:"api_key"`
	APISecret string `json:"api_secret" mapstructure:"api_secret"`
	BaseURL   string `json:"base_url"   mapstructure:"base_url"`
	Insecure  bool   `json:"insecure"   mapstructure:"insecure"`
}

Config represents the API configuration

type DNSOverride

type DNSOverride struct {
	UUID        string `json:"uuid,omitempty"`
	Enabled     string `json:"enabled"`
	Host        string `json:"hostname"`
	Domain      string `json:"domain"`
	RR          string `json:"rr,omitempty"`
	MXPrio      string `json:"mxprio,omitempty"`
	MX          string `json:"mx,omitempty"`
	Server      string `json:"server"`
	Description string `json:"description"`
}

DNSOverride represents a single DNS override entry

Jump to

Keyboard shortcuts

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