Documentation
¶
Overview ¶
cloudflare.go in internal/api package
Index ¶
- type APIResponse
- type AdguardClient
- func (a *AdguardClient) AddRewrite(domain, answer string) error
- func (a *AdguardClient) DeleteRewrite(domain, answer string) error
- func (a *AdguardClient) GetRewritesForDomain(domain string) ([]Rewrite, error)
- func (a *AdguardClient) ListRewrites() ([]Rewrite, error)
- func (a *AdguardClient) RewriteExists(domain, answer string) (bool, error)
- func (a *AdguardClient) UpdateRewrite(target, update Rewrite) error
- type AdguardConfig
- 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 CloudflareClient
- type CloudflareConfig
- type CloudflareTunnel
- type CloudflareTunnelConnection
- type Config
- type DNSOverride
- type Rewrite
- type RewriteUpdate
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 AdguardClient ¶ added in v0.1.0
type AdguardClient struct {
BaseURL string
Username string
Password string
Prompt bool // Enable interactive prompting for API calls
// contains filtered or unexported fields
}
AdguardClient handles communication with the AdguardHome DNS rewrite API
func NewAdguardClient ¶ added in v0.1.0
func NewAdguardClient(config AdguardConfig) *AdguardClient
NewAdguardClient creates a new AdguardHome API client
func NewAdguardClientFromConfig ¶ added in v0.1.0
func NewAdguardClientFromConfig(config Config, adguardBaseURL string) *AdguardClient
NewAdguardClientFromConfig creates an AdguardHome client from existing API config
func (*AdguardClient) AddRewrite ¶ added in v0.1.0
func (a *AdguardClient) AddRewrite(domain, answer string) error
AddRewrite adds a new DNS rewrite rule
func (*AdguardClient) DeleteRewrite ¶ added in v0.1.0
func (a *AdguardClient) DeleteRewrite(domain, answer string) error
DeleteRewrite removes a DNS rewrite rule
func (*AdguardClient) GetRewritesForDomain ¶ added in v0.1.0
func (a *AdguardClient) GetRewritesForDomain(domain string) ([]Rewrite, error)
GetRewritesForDomain returns all rewrite rules for a specific domain
func (*AdguardClient) ListRewrites ¶ added in v0.1.0
func (a *AdguardClient) ListRewrites() ([]Rewrite, error)
ListRewrites retrieves all DNS rewrite rules
func (*AdguardClient) RewriteExists ¶ added in v0.1.0
func (a *AdguardClient) RewriteExists(domain, answer string) (bool, error)
RewriteExists checks if a specific rewrite rule exists
func (*AdguardClient) UpdateRewrite ¶ added in v0.1.0
func (a *AdguardClient) UpdateRewrite(target, update Rewrite) error
UpdateRewrite updates an existing DNS rewrite rule
type AdguardConfig ¶ added in v0.1.0
type AdguardConfig struct {
BaseURL string `json:"base_url" mapstructure:"base_url"`
Username string `json:"username" mapstructure:"username"`
Password string `json:"password" mapstructure:"password"`
Insecure bool `json:"insecure" mapstructure:"insecure"`
Enabled bool `json:"enabled" mapstructure:"enabled"`
}
AdguardConfig represents configuration for AdguardHome 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 {
Prompt bool // Enable interactive prompting for API calls
// 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 CloudflareClient ¶ added in v0.1.0
type CloudflareClient struct {
// contains filtered or unexported fields
}
CloudflareClient handles communication with the Cloudflare API
func NewCloudflareClient ¶ added in v0.1.0
func NewCloudflareClient(config CloudflareConfig) (*CloudflareClient, error)
NewCloudflareClient creates a new Cloudflare API client
func (*CloudflareClient) AddTunnelHostname ¶ added in v0.1.0
func (c *CloudflareClient) AddTunnelHostname(hostname, service string) error
AddTunnelHostname adds a new hostname to the tunnel configuration
func (*CloudflareClient) DeleteTunnelHostname ¶ added in v0.1.0
func (c *CloudflareClient) DeleteTunnelHostname(hostname string) error
DeleteTunnelHostname removes a hostname from the tunnel configuration
func (*CloudflareClient) GetTunnelHostnames ¶ added in v0.1.0
func (c *CloudflareClient) GetTunnelHostnames() (map[string]string, error)
GetTunnelHostnames returns all hostnames configured for the tunnel
func (*CloudflareClient) ListTunnels ¶ added in v0.1.0
func (c *CloudflareClient) ListTunnels() ([]CloudflareTunnel, error)
ListTunnels returns a list of all tunnels for the account
type CloudflareConfig ¶ added in v0.1.0
CloudflareConfig contains configuration for Cloudflare API
type CloudflareTunnel ¶ added in v0.1.0
type CloudflareTunnel struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
DeletedAt time.Time `json:"deleted_at"`
Connections []CloudflareTunnelConnection `json:"connections"`
}
CloudflareTunnel represents a Cloudflare tunnel
type CloudflareTunnelConnection ¶ added in v0.1.0
type CloudflareTunnelConnection struct {
ID string `json:"id"`
ConnectedAt time.Time `json:"connected_at"`
Status string `json:"status"`
}
CloudflareTunnelConnection represents a connection to a Cloudflare tunnel
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
type RewriteUpdate ¶ added in v0.1.0
RewriteUpdate represents the structure for updating a rewrite rule