Documentation
¶
Index ¶
- type APIResponse
- type CaddyClient
- type Client
- func (c *Client) AddOverride(override DNSOverride) (string, error)
- func (c *Client) ApplyChanges() error
- func (c *Client) DeleteOverride(uuid string) error
- func (c *Client) GetOverrides() ([]DNSOverride, error)
- func (c *Client) IsOverrideExists(host, domain string) (bool, string, error)
- func (c *Client) UpdateOverride(override DNSOverride) error
- type Config
- type DNSOverride
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 ¶
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 (*Client) AddOverride ¶
func (c *Client) AddOverride(override DNSOverride) (string, error)
AddOverride creates a new DNS override
func (*Client) ApplyChanges ¶
ApplyChanges applies all DNS changes to the Unbound service
func (*Client) DeleteOverride ¶
DeleteOverride removes a DNS override
func (*Client) GetOverrides ¶
func (c *Client) GetOverrides() ([]DNSOverride, error)
GetOverrides retrieves all DNS overrides
func (*Client) IsOverrideExists ¶
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