Documentation
¶
Index ¶
- Variables
- func GetURLCacheTTL() time.Duration
- func LoadConfig(configPath string) error
- func ValidateDnsRoutingGroups(groups []DnsRoutingGroup) error
- func ValidateDomainList(domains []string, groupName string) error
- type BatFileList
- type BatLists
- type BatURLList
- type Cache
- type DNS
- type DnsRecord
- type DnsRoutes
- type DnsRoutingGroup
- type DomainFileList
- type DomainLists
- type DomainURLList
- type GokeenapiConfig
- type GroupsList
- type Keenetic
- type Logs
- type Route
- type Runtime
- type ScheduledCommand
- type ScheduledTask
- type SchedulerConfig
Constants ¶
This section is empty.
Variables ¶
var (
Cfg = GokeenapiConfig{}
)
Functions ¶
func GetURLCacheTTL ¶ added in v1.6.1
GetURLCacheTTL returns the configured URL cache TTL Returns 1 minute as default if not configured
func LoadConfig ¶
func ValidateDnsRoutingGroups ¶ added in v1.6.0
func ValidateDnsRoutingGroups(groups []DnsRoutingGroup) error
ValidateDnsRoutingGroups validates DNS routing group configurations
func ValidateDomainList ¶ added in v1.6.0
ValidateDomainList validates a list of domains/IPs
Types ¶
type BatFileList ¶ added in v1.5.0
type BatFileList struct {
// BatFile contains list of paths to .bat files or .yaml/.yml files
// When a .yaml/.yml file is specified, it's loaded and expanded to its contained bat-file paths
// This allows sharing common bat-file lists across multiple configurations
// Example YAML structure: bat-file: ["/path/to/file1.bat", "/path/to/file2.bat"]
BatFile []string `yaml:"bat-file"`
}
BatFileList represents the structure of a YAML file containing bat-file paths
type BatLists ¶ added in v1.5.1
type BatLists struct {
BatFileList `yaml:",inline"`
BatURLList `yaml:",inline"`
}
BatLists combines both bat-file and bat-url lists for efficient loading
type BatURLList ¶ added in v1.5.1
type BatURLList struct {
// BatURL contains list of URLs to remote .bat files or .yaml/.yml files
// When a .yaml/.yml file is specified, it's loaded and expanded to its contained bat-url paths
// This allows sharing common bat-url lists across multiple configurations
// Example YAML structure: bat-url: ["https://example.com/file1.bat", "https://example.com/file2.bat"]
BatURL []string `yaml:"bat-url"`
}
BatURLList represents the structure of a YAML file containing bat-url paths
type Cache ¶ added in v1.6.1
type Cache struct {
// URLTTL specifies how long to cache downloaded content from URLs
// Default: 1m if not specified
// Examples: "1m", "5m", "1h", "30s"
// Used for bat-url and domain-url downloads to reduce network requests
URLTTL time.Duration `yaml:"urlTtl,omitempty"`
}
Cache contains caching configuration options
type DNS ¶
type DNS struct {
// Records contains list of DNS records to manage
Records []DnsRecord `yaml:"records"`
// Routes contains DNS-routing configuration
Routes DnsRoutes `yaml:"routes"`
}
DNS contains DNS-related configuration
type DnsRecord ¶
type DnsRecord struct {
// Domain name for the DNS record
Domain string `yaml:"domain"`
// IP addresses associated with the domain (supports multiple IPs)
IP []string `yaml:"ip"`
}
DnsRecord represents a single DNS record with domain and IP addresses
type DnsRoutes ¶ added in v1.6.0
type DnsRoutes struct {
// Groups contains list of domain groups with routing policies
// Can also reference .yaml/.yml files containing lists of groups for sharing common configurations
// When a string ending with .yaml/.yml is specified, it's loaded and its groups are expanded inline
// Example:
// groups:
// - common_dns_groups.yaml # Import groups from file
// - name: local-group # Regular group definition
// domain-file: [domains/local.txt]
// interfaceId: Wireguard0
Groups []DnsRoutingGroup `yaml:"groups"`
}
DnsRoutes contains DNS-routing configuration
type DnsRoutingGroup ¶ added in v1.6.0
type DnsRoutingGroup struct {
// Name is the unique identifier for the object-group
Name string `yaml:"name"`
// File is an alternative to Name for importing groups from a YAML file with optional interfaceId override
// Example: {file: common_dns_groups.yaml, interfaceId: Wireguard4}
File string `yaml:"file"`
// DomainFile contains list of local .txt files with domains (one per line)
// Can also reference .yaml files containing lists of domain-file paths
DomainFile []string `yaml:"domain-file"`
// DomainURL contains list of remote URLs serving .txt files with domains
DomainURL []string `yaml:"domain-url"`
// InterfaceID specifies the target interface for routing
InterfaceID string `yaml:"interfaceId"`
// contains filtered or unexported fields
}
DnsRoutingGroup represents a domain group with associated routing policy
func (*DnsRoutingGroup) UnmarshalYAML ¶ added in v1.7.0
func (g *DnsRoutingGroup) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements custom unmarshaling for DnsRoutingGroup to support both string references (file paths) and object definitions (groups)
type DomainFileList ¶ added in v1.6.0
type DomainFileList struct {
// DomainFile contains list of paths to .txt files or .yaml/.yml files
// When a .yaml/.yml file is specified, it's loaded and expanded to its contained domain-file paths
// This allows sharing common domain-file lists across multiple configurations
// Example YAML structure: domain-file: ["/path/to/file1.txt", "/path/to/file2.txt"]
DomainFile []string `yaml:"domain-file"`
}
DomainFileList represents the structure of a YAML file containing domain-file paths
type DomainLists ¶ added in v1.6.0
type DomainLists struct {
DomainFileList `yaml:",inline"`
DomainURLList `yaml:",inline"`
}
DomainLists combines both domain-file and domain-url lists for efficient loading
type DomainURLList ¶ added in v1.6.0
type DomainURLList struct {
// DomainURL contains list of URLs to remote .txt files or .yaml/.yml files
// When a .yaml/.yml file is specified, it's loaded and expanded to its contained domain-url paths
// This allows sharing common domain-url lists across multiple configurations
// Example YAML structure: domain-url: ["https://example.com/file1.txt", "https://example.com/file2.txt"]
DomainURL []string `yaml:"domain-url"`
}
DomainURLList represents the structure of a YAML file containing domain-url paths
type GokeenapiConfig ¶
type GokeenapiConfig struct {
// Keenetic router connection settings
Keenetic Keenetic `yaml:"keenetic"`
// DataDir specifies custom data directory for storing application data (optional)
DataDir string `yaml:"dataDir,omitempty"`
// Routes contains list of routing configurations for different interfaces
Routes []Route `yaml:"routes"`
// DNS contains DNS records configuration
DNS DNS `yaml:"dns"`
// Logs contains logging configuration (optional)
Logs Logs `yaml:"logs,omitempty"`
// Cache contains caching configuration (optional)
Cache Cache `yaml:"cache,omitempty"`
}
GokeenapiConfig represents the main configuration structure for the application
type GroupsList ¶ added in v1.7.0
type GroupsList struct {
// Groups contains list of DNS routing groups to be imported
// This allows sharing common DNS routing group configurations across multiple router configs
// Example YAML structure:
// groups:
// - name: youtube
// domain-url: [domains/youtube.yaml]
// interfaceId: Wireguard0
// - name: telegram
// domain-url: [domains/telegram.yaml]
// interfaceId: Wireguard0
Groups []DnsRoutingGroup `yaml:"groups"`
}
GroupsList represents the structure of a YAML file containing DNS routing groups
type Keenetic ¶
type Keenetic struct {
// URL of the router (IP address or KeenDNS hostname with http/https)
URL string `yaml:"url"`
// Login for router admin access (can be overridden by GOKEENAPI_KEENETIC_LOGIN env var)
Login string `yaml:"login"`
// Password for router admin access (can be overridden by GOKEENAPI_KEENETIC_PASSWORD env var)
Password string `yaml:"password"`
// TLSSkipVerify disables TLS certificate verification when connecting to the router over HTTPS.
// Enable this when the router uses a self-signed certificate.
// Default: false (verification enabled, secure)
TLSSkipVerify bool `yaml:"tls_skip_verify,omitempty"`
// Timeout specifies the HTTP request timeout for API calls.
// Default: 30s if not specified.
// Examples: "30s", "1m", "10s"
Timeout time.Duration `yaml:"timeout,omitempty"`
}
Keenetic holds connection parameters for the Keenetic router
type Logs ¶
type Logs struct {
// Debug enables debug-level logging for troubleshooting
Debug bool `yaml:"debug"`
}
Logs contains logging configuration options
type Route ¶
type Route struct {
// InterfaceID specifies the target interface (e.g., Wireguard0)
InterfaceID string `yaml:"interfaceId"`
// BatFileList is embedded to reuse the BatFile field definition
BatFileList `yaml:",inline"`
// BatURLList is embedded to reuse the BatURL field definition
BatURLList `yaml:",inline"`
}
Route defines routing configuration for a specific interface
type Runtime ¶ added in v1.1.0
type Runtime struct {
RouterInfo struct {
Version gokeenrestapimodels.Version `yaml:"-"`
} `yaml:"-"`
}
Runtime holds runtime configuration that is not persisted to YAML
type ScheduledCommand ¶ added in v1.7.1
type ScheduledCommand struct {
// Name is the gokeenapi command to run (e.g., "add-routes", "delete-all-dns-routing")
Name string
// Args contains extra flags/arguments appended after the command name (e.g., ["--force"])
Args []string
}
ScheduledCommand represents a single command with optional extra arguments. It can be specified as a plain string (backward-compatible) or as an object:
# string form
commands:
- add-dns-routing
# object form (with extra flags)
commands:
- name: delete-all-dns-routing
args: ["--force"]
func (*ScheduledCommand) UnmarshalYAML ¶ added in v1.7.1
func (c *ScheduledCommand) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements custom unmarshaling so that a plain string and an object {name: ..., args: [...]} are both valid.
type ScheduledTask ¶ added in v1.4.0
type ScheduledTask struct {
// Name is a descriptive name for the task
Name string `yaml:"name"`
// Commands is the list of gokeenapi commands to execute sequentially.
// Each entry can be a plain string or an object with name and args fields.
Commands []ScheduledCommand `yaml:"commands"`
// Configs contains paths to config files to use for this task
Configs []string `yaml:"configs"`
// Interval specifies execution interval (e.g., "3h", "30m", "1h30m")
Interval string `yaml:"interval,omitempty"`
// Times specifies fixed execution times in 24h format (e.g., ["06:00", "12:00", "18:00"])
Times []string `yaml:"times,omitempty"`
// Retry specifies number of retry attempts on failure (default: 0)
Retry int `yaml:"retry,omitempty"`
// RetryDelay specifies delay between retries (e.g., "30s", "1m", default: "1m")
RetryDelay string `yaml:"retryDelay,omitempty"`
// Strategy defines execution strategy: "parallel" for concurrent execution across all configs, default is sequential
Strategy string `yaml:"strategy,omitempty"`
}
ScheduledTask defines a single scheduled task
type SchedulerConfig ¶ added in v1.4.0
type SchedulerConfig struct {
// Tasks contains list of scheduled tasks to execute
Tasks []ScheduledTask `yaml:"tasks"`
}
SchedulerConfig represents scheduler configuration structure
func LoadSchedulerConfig ¶ added in v1.4.0
func LoadSchedulerConfig(configPath string) (SchedulerConfig, error)
LoadSchedulerConfig loads scheduler configuration from YAML file