adguard

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 7 Imported by: 1

README

AdGuard Home Go SDK

Release GoDoc License Status Go Report Card

Updated to version 0.107.48 of the upstream API.

This was written primarily for use in my Terraform provider for AdGuard Home.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADG

type ADG struct {
	HostURL    string
	HTTPClient *http.Client
	Auth       AuthStruct
}

ADG Client

func NewClient

func NewClient(host, username, password, scheme *string, timeout *int) (*ADG, error)

NewClient

func (*ADG) ConfigureFiltering added in v0.5.0

func (c *ADG) ConfigureFiltering(filterConfig FilterConfig) (*FilterConfig, error)

ConfigureFiltering - Configure DNS server filtering parameters

func (*ADG) CreateClient

func (c *ADG) CreateClient(client Client) (*Client, error)

CreateClient - Create a client

func (*ADG) CreateListFilter added in v0.2.1

func (c *ADG) CreateListFilter(filterData AddUrlRequest) (*Filter, bool, error)

CreateListFilter - Create a list filter, returning the created filter and whether it's a whitelist filter

func (*ADG) CreateRewrite added in v0.3.0

func (c *ADG) CreateRewrite(rewrite RewriteEntry) (*RewriteEntry, error)

CreateRewrite - Create a DNS rewrite rule

func (*ADG) DeleteClient

func (c *ADG) DeleteClient(clientDelete ClientDelete) error

DeleteClient - Deletes a client

func (*ADG) DeleteListFilter added in v0.2.1

func (c *ADG) DeleteListFilter(filterDelete RemoveUrlRequest) error

DeleteListFilter - Deletes a list filter

func (*ADG) DeleteRewrite added in v0.3.0

func (c *ADG) DeleteRewrite(domain string) error

DeleteRewrite - Delete a DNS rewrite rule based on the domain

func (*ADG) GetAccess added in v0.4.0

func (c *ADG) GetAccess() (*AccessList, error)

GetAccess - Returns the current access list

func (*ADG) GetAllClients added in v0.8.0

func (c *ADG) GetAllClients() (*AllClients, error)

GetAllClients - Returns all clients

func (*ADG) GetAllFilters added in v0.2.1

func (c *ADG) GetAllFilters() (*FilterStatus, error)

GetAllFilter - Returns all filters

func (*ADG) GetAllRewrites added in v0.3.0

func (c *ADG) GetAllRewrites() (*[]RewriteEntry, error)

GetAllRewrites - Returns all DNS rewrite rules

func (*ADG) GetBlockedServices added in v0.5.0

func (c *ADG) GetBlockedServices() (*BlockedServicesSchedule, error)

GetBlockedServices - Returns the services that are blocked globally

func (*ADG) GetBlockedServicesList added in v0.5.0

func (c *ADG) GetBlockedServicesList() (*BlockedServicesAll, error)

GetBlockedServicesList - Returns the list of all available services to be blocked

func (*ADG) GetClient

func (c *ADG) GetClient(identifier string) (*Client, error)

GetClient - Returns a client based on an identifier

func (*ADG) GetDhcpInterfaces added in v0.6.0

func (c *ADG) GetDhcpInterfaces() (*NetInterfaces, error)

GetDhcpStatus - Returns the available DHCP interfaces

func (*ADG) GetDhcpStatus added in v0.6.0

func (c *ADG) GetDhcpStatus() (*DhcpStatus, error)

GetDhcpStatus - Returns the current DHCP status

func (*ADG) GetDnsInfo added in v0.4.0

func (c *ADG) GetDnsInfo() (*DNSInfo, error)

GetDnsInfo - Returns the current DNS parameters

func (*ADG) GetListFilterById added in v0.2.1

func (c *ADG) GetListFilterById(id int64) (*Filter, bool, error)

GetListFilterById - Returns a list filter based on its name and whether it's a whitelist filter

func (*ADG) GetListFilterByName added in v0.2.1

func (c *ADG) GetListFilterByName(listName string) (*Filter, bool, error)

GetListFilterByName - Returns a list filter based on its name and whether it's a whitelist filter

func (*ADG) GetParentalStatus added in v0.5.0

func (c *ADG) GetParentalStatus() (*bool, error)

GetParentalStatus - Returns whether parental control is enabled or not

func (*ADG) GetQueryLogConfig added in v0.5.0

func (c *ADG) GetQueryLogConfig() (*GetQueryLogConfigResponse, error)

GetQueryLogConfig - Returns query log configuration parameters

func (*ADG) GetRewrite added in v0.3.0

func (c *ADG) GetRewrite(domain string) (*RewriteEntry, error)

GetRewrite - Return a DNS rewrite rule based on the domain

func (*ADG) GetSafeBrowsingStatus added in v0.5.0

func (c *ADG) GetSafeBrowsingStatus() (*bool, error)

GetSafeBrowsingStatus - Returns whether safe-browsing is enabled or not

func (*ADG) GetSafeSearchConfig added in v0.5.0

func (c *ADG) GetSafeSearchConfig() (*SafeSearchConfig, error)

GetSafeSearchStatus - Retrieve safe search configuration

func (*ADG) GetStatsConfig added in v0.5.0

func (c *ADG) GetStatsConfig() (*GetStatsConfigResponse, error)

GetStatsConfig - Returns statistics configuration parameters

func (*ADG) GetTlsConfig added in v0.6.0

func (c *ADG) GetTlsConfig() (*TlsConfig, error)

GetTlsConfig - Returns TLS configuration and status

func (*ADG) GetUserRules added in v0.2.1

func (c *ADG) GetUserRules() (*[]string, error)

GetUserRules - Returns a list of all user rules

func (*ADG) ManageDhcpStaticLease added in v0.6.0

func (c *ADG) ManageDhcpStaticLease(add bool, dhcpStaticLease DhcpStaticLease) (*DhcpStaticLease, error)

ManageDhcpStaticLease - Add ot remove a DHCP static lease

func (*ADG) ResetDhcpConfig added in v0.6.0

func (c *ADG) ResetDhcpConfig() error

ResetDhcpConfig - reset all DHCP configuration to defaults

func (*ADG) ResetDhcpStaticLeases added in v0.6.0

func (c *ADG) ResetDhcpStaticLeases() error

ResetDhcpStaticLeases - reset all DHCP static leases

func (*ADG) SetAccess added in v0.4.0

func (c *ADG) SetAccess(accessList AccessList) (*AccessList, error)

SetAccess - Sets the access list

func (*ADG) SetBlockedServices added in v0.5.0

func (c *ADG) SetBlockedServices(blockedServicesSchedule BlockedServicesSchedule) (*BlockedServicesSchedule, error)

UpdateBlockedServices - Update blocked services

func (*ADG) SetDhcpConfig added in v0.6.0

func (c *ADG) SetDhcpConfig(dhcpConfig DhcpConfig) (*DhcpConfig, error)

SetDhcpConfig - Sets DHCP server configuration

func (*ADG) SetDnsConfig added in v0.4.0

func (c *ADG) SetDnsConfig(dnsConfig DNSConfig) (*DNSConfig, error)

SetDnsConfig - Sets DNS parameters

func (*ADG) SetParentalStatus added in v0.5.0

func (c *ADG) SetParentalStatus(status bool) error

SetParentalStatus - Enable or disable parental controls

func (*ADG) SetQueryLogConfig added in v0.5.0

func (c *ADG) SetQueryLogConfig(queryLogConfig GetQueryLogConfigResponse) (*GetQueryLogConfigResponse, error)

SetQueryLogConfig - Sets query log configuration parameters

func (*ADG) SetSafeBrowsingStatus added in v0.5.0

func (c *ADG) SetSafeBrowsingStatus(status bool) error

SetSafeBrowsingStatus - Enable or disable safe-browsing

func (*ADG) SetSafeSearchConfig added in v0.5.0

func (c *ADG) SetSafeSearchConfig(safeSearchConfig SafeSearchConfig) (*SafeSearchConfig, error)

SetSafeSearchConfig - Set safe search configuration

func (*ADG) SetStatsConfig added in v0.5.0

func (c *ADG) SetStatsConfig(statsConfig GetStatsConfigResponse) (*GetStatsConfigResponse, error)

SetStatsConfig - Sets statistics configuration parameters

func (*ADG) SetTlsConfig added in v0.6.0

func (c *ADG) SetTlsConfig(tlsConfig TlsConfig) (*TlsConfig, error)

SetAccess - Sets the access list

func (*ADG) UpdateClient

func (c *ADG) UpdateClient(clientUpdate ClientUpdate) (*Client, error)

UpdateClient - Update a client

func (*ADG) UpdateListFilter added in v0.2.1

func (c *ADG) UpdateListFilter(filterUpdate FilterSetUrl) (*Filter, bool, error)

UpdateListFilter - Update a list filter, returning the updated filter and whether it's a whitelist filter

func (*ADG) UpdateRewrite added in v0.3.0

func (c *ADG) UpdateRewrite(rewrite RewriteEntry) (*RewriteEntry, error)

UpdateRewrite - Update a DNS rewrite rule

func (*ADG) UpdateUserRules added in v0.2.1

func (c *ADG) UpdateUserRules(rules SetRulesRequest) (*[]string, error)

UpdateUserRules - Update user-provided rules, returning the list of all user rules

type AccessList added in v0.4.0

type AccessList struct {
	AllowedClients    []string `json:"allowed_clients"`
	DisallowedClients []string `json:"disallowed_clients"`
	BlockedHosts      []string `json:"blocked_hosts"`
}

AccessList

type AddUrlRequest added in v0.2.1

type AddUrlRequest struct {
	Name      string `json:"name"`
	Url       string `json:"url"`
	Whitelist bool   `json:"whitelist"`
}

AddUrlRequest

type AllClients

type AllClients struct {
	Clients       []Client     `json:"clients"`
	ClientAuto    []ClientAuto `json:"auto_clients"`
	SupportedTags []string     `json:"supported_tags"`
}

AllClients

type AuthStruct

type AuthStruct struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

AuthStruct

type BlockedService added in v0.5.0

type BlockedService struct {
	IconSvg string   `json:"icon_svg"`
	Id      string   `json:"id"`
	Name    string   `json:"name"`
	Rules   []string `json:"rules"`
}

BlockedService

type BlockedServicesAll added in v0.5.0

type BlockedServicesAll struct {
	BlockedServices []BlockedService `json:"blocked_services"`
}

BlockedServicesAll

type BlockedServicesSchedule added in v0.7.0

type BlockedServicesSchedule struct {
	Schedule Schedule `json:"schedule,omitempty"`
	Ids      []string `json:"ids"`
}

BlockedServicesSchedule

type Client

type Client struct {
	Name                     string           `json:"name"`
	Ids                      []string         `json:"ids"`
	UseGlobalSettings        bool             `json:"use_global_settings"`
	FilteringEnabled         bool             `json:"filtering_enabled"`
	ParentalEnabled          bool             `json:"parental_enabled"`
	SafebrowsingEnabled      bool             `json:"safebrowsing_enabled"`
	SafesearchEnabled        bool             `json:"safesearch_enabled"` // deprecated
	SafeSearch               SafeSearchConfig `json:"safe_search"`
	UseGlobalBlockedServices bool             `json:"use_global_blocked_services"`
	BlockedServicesSchedule  Schedule         `json:"blocked_services_schedule"`
	BlockedServices          []string         `json:"blocked_services"`
	Upstreams                []string         `json:"upstreams"`
	Tags                     []string         `json:"tags"`
	IgnoreQuerylog           bool             `json:"ignore_querylog"`
	IgnoreStatistics         bool             `json:"ignore_statistics"`
	UpstreamsCacheEnabled    bool             `json:"upstreams_cache_enabled"`
	UpstreamsCacheSize       uint             `json:"upstreams_cache_size"`
}

Client

type ClientAuto

type ClientAuto struct {
	Name      string            `json:"name"`
	Ip        string            `json:"ip"`
	Source    string            `json:"source"`
	WhoisInfo map[string]string `json:"whois_info"`
}

ClientAuto

type ClientDelete

type ClientDelete struct {
	Name string `json:"name"`
}

ClientDelete

type ClientUpdate

type ClientUpdate struct {
	Name string `json:"name"`
	Data Client `json:"data"`
}

ClientUpdate

type DNSConfig added in v0.4.0

type DNSConfig struct {
	BootstrapDns                 []string `json:"bootstrap_dns"`
	UpstreamDns                  []string `json:"upstream_dns"`
	FallbackDns                  []string `json:"fallback_dns"`
	UpstreamDnsFile              string   `json:"upstream_dns_file"`
	ProtectionEnabled            bool     `json:"protection_enabled"`
	RateLimit                    uint     `json:"ratelimit"`
	RateLimitSubnetSubnetLenIpv4 uint     `json:"ratelimit_subnet_len_ipv4"`
	RateLimitSubnetSubnetLenIpv6 uint     `json:"ratelimit_subnet_len_ipv6"`
	RateLimitWhitelist           []string `json:"ratelimit_whitelist"`
	BlockingMode                 string   `json:"blocking_mode"`
	BlockingIpv4                 string   `json:"blocking_ipv4"`
	BlockingIpv6                 string   `json:"blocking_ipv6"`
	BlockedResponseTtl           uint     `json:"blocked_response_ttl"`
	EDnsCsEnabled                bool     `json:"edns_cs_enabled"`
	EDnsCsUseCustom              bool     `json:"edns_cs_use_custom"`
	EDnsCsCustomIp               string   `json:"edns_cs_custom_ip"`
	DisableIpv6                  bool     `json:"disable_ipv6"`
	DnsSecEnabled                bool     `json:"dnssec_enabled"`
	CacheSize                    uint     `json:"cache_size"`
	CacheTtlMin                  uint     `json:"cache_ttl_min"`
	CacheTtlMax                  uint     `json:"cache_ttl_max"`
	CacheOptimistic              bool     `json:"cache_optimistic"`
	UpstreamMode                 string   `json:"upstream_mode"`
	UsePrivatePtrResolvers       bool     `json:"use_private_ptr_resolvers"`
	ResolveClients               bool     `json:"resolve_clients"`
	LocalPtrUpstreams            []string `json:"local_ptr_upstreams"`
}

DNSConfig

type DNSInfo added in v0.4.0

type DNSInfo struct {
	*DNSConfig
	DefaultLocalPtrUpstreams []string `json:"default_local_ptr_upstreams"`
}

DNSInfo

type DayRange added in v0.7.0

type DayRange struct {
	Start uint `json:"start,omitempty"`
	End   uint `json:"end,omitempty"`
}

DayRange

type DhcpConfig added in v0.6.0

type DhcpConfig struct {
	Enabled       bool         `json:"enabled"`
	InterfaceName string       `json:"interface_name"`
	V4            DhcpConfigV4 `json:"v4,omitempty"`
	V6            DhcpConfigV6 `json:"v6,omitempty"`
}

DhcpConfig

type DhcpConfigV4 added in v0.6.0

type DhcpConfigV4 struct {
	GatewayIp     string `json:"gateway_ip,omitempty"`
	SubnetMask    string `json:"subnet_mask,omitempty"`
	RangeStart    string `json:"range_start,omitempty"`
	RangeEnd      string `json:"range_end,omitempty"`
	LeaseDuration uint64 `json:"lease_duration,omitempty"`
}

DhcpConfigV4

type DhcpConfigV6 added in v0.6.0

type DhcpConfigV6 struct {
	RangeStart    string `json:"range_start,omitempty"`
	LeaseDuration uint64 `json:"lease_duration,omitempty"`
}

DhcpConfigV6

type DhcpLease added in v0.6.0

type DhcpLease struct {
	Mac      string `json:"mac"`
	Ip       string `json:"ip"`
	Hostname string `json:"hostname"`
	Expires  string `json:"expires"`
}

DhcpLease

type DhcpStaticLease added in v0.6.0

type DhcpStaticLease struct {
	Mac      string `json:"mac"`
	Ip       string `json:"ip"`
	Hostname string `json:"hostname"`
}

DhcpStaticLease

type DhcpStatus added in v0.6.0

type DhcpStatus struct {
	Enabled       bool              `json:"enabled"`
	InterfaceName string            `json:"interface_name"`
	V4            DhcpConfigV4      `json:"v4"`
	V6            DhcpConfigV6      `json:"v6"`
	Leases        []DhcpLease       `json:"leases"`
	StaticLeases  []DhcpStaticLease `json:"static_leases"`
}

DhcpStatus

type Enabled added in v0.5.0

type Enabled struct {
	Enabled bool `json:"enabled"`
}

Enabled

type Filter added in v0.2.1

type Filter struct {
	Enabled     bool   `json:"enabled"`
	Id          int64  `json:"id"`
	LastUpdated string `json:"last_updated"`
	Name        string `json:"name"`
	RulesCount  int32  `json:"rules_count"`
	Url         string `json:"url"`
}

Filter

type FilterConfig added in v0.5.0

type FilterConfig struct {
	Enabled  bool `json:"enabled"`
	Interval uint `json:"interval"`
}

FilterConfig

type FilterSetUrl added in v0.2.1

type FilterSetUrl struct {
	Data      FilterSetUrlData `json:"data"`
	Url       string           `json:"url"`
	Whitelist bool             `json:"whitelist"`
}

FilterSetUrl

type FilterSetUrlData added in v0.2.1

type FilterSetUrlData struct {
	Enabled bool   `json:"enabled"`
	Name    string `json:"name"`
	Url     string `json:"url"`
}

FilterSetUrlData

type FilterStatus added in v0.2.1

type FilterStatus struct {
	Enabled          bool     `json:"enabled"`
	Interval         uint     `json:"interval"`
	Filters          []Filter `json:"filters"`
	WhitelistFilters []Filter `json:"whitelist_filters"`
	UserRules        []string `json:"user_rules"`
}

FilterStatus

type GetQueryLogConfigResponse added in v0.5.0

type GetQueryLogConfigResponse struct {
	Enabled           bool     `json:"enabled"`
	Interval          uint64   `json:"interval"`
	AnonymizeClientIp bool     `json:"anonymize_client_ip"`
	Ignored           []string `json:"ignored"`
}

GetQueryLogConfigResponse

type GetStatsConfigResponse added in v0.5.0

type GetStatsConfigResponse struct {
	Enabled  bool     `json:"enabled"`
	Interval uint64   `json:"interval"`
	Ignored  []string `json:"ignored"`
}

GetStatsConfigResponse

type NetInterface added in v0.6.0

type NetInterface struct {
	Flags           string   `json:"flags"`
	HardwareAddress string   `json:"hardware_address"`
	Name            string   `json:"name"`
	IpAddresses     []string `json:"ip_addresses"`
	Mtu             int      `json:"mtu"`
}

NetInterface

type NetInterfaces added in v0.6.0

type NetInterfaces struct {
	Name NetInterface
}

NetInterfaces

type RemoveUrlRequest added in v0.2.1

type RemoveUrlRequest struct {
	Url       string `json:"url"`
	Whitelist bool   `json:"whitelist"`
}

RemoveUrlRequest

type RewriteEntry added in v0.3.0

type RewriteEntry struct {
	Domain string `json:"domain"`
	Answer string `json:"answer"`
}

RewriteEntry

type SafeSearchConfig added in v0.5.0

type SafeSearchConfig struct {
	Enabled    bool `json:"enabled"`
	Bing       bool `json:"bing"`
	Duckduckgo bool `json:"duckduckgo"`
	Google     bool `json:"google"`
	Pixabay    bool `json:"pixabay"`
	Yandex     bool `json:"yandex"`
	Youtube    bool `json:"youtube"`
}

SafeSearchConfig

type Schedule added in v0.7.0

type Schedule struct {
	TimeZone  string   `json:"time_zone,omitempty"`
	Sunday    DayRange `json:"sun,omitempty"`
	Monday    DayRange `json:"mon,omitempty"`
	Tuesday   DayRange `json:"tue,omitempty"`
	Wednesday DayRange `json:"wed,omitempty"`
	Thursday  DayRange `json:"thu,omitempty"`
	Friday    DayRange `json:"fri,omitempty"`
	Saturday  DayRange `json:"sat,omitempty"`
}

Schedule

type SetRulesRequest added in v0.2.1

type SetRulesRequest struct {
	Rules []string `json:"rules"`
}

SetRulesRequest

type TlsConfig added in v0.6.0

type TlsConfig struct {
	Enabled           bool     `json:"enabled"`
	ServerName        string   `json:"server_name"`
	ForceHttps        bool     `json:"force_https"`
	PortHttps         uint16   `json:"port_https"`
	PortDnsOverTls    uint16   `json:"port_dns_over_tls"`
	PortDnsOverQuic   uint16   `json:"port_dns_over_quic"`
	CertificateChain  string   `json:"certificate_chain"`
	PrivateKey        string   `json:"private_key"`
	PrivateKeySaved   bool     `json:"private_key_saved"`
	CertificatePath   string   `json:"certificate_path"`
	PrivateKeyPath    string   `json:"private_key_path"`
	ValidCert         bool     `json:"valid_cert"`
	ValidChain        bool     `json:"valid_chain"`
	Subject           string   `json:"subject"`
	Issuer            string   `json:"issuer"`
	NotBefore         string   `json:"not_before"`
	NotAfter          string   `json:"not_after"`
	DnsNames          []string `json:"dns_names"`
	ValidKey          bool     `json:"valid_key"`
	KeyType           string   `json:"key_type"`
	WarningValidation string   `json:"warning_validation"`
	ValidPair         bool     `json:"valid_pair"`
	ServePlainDns     bool     `json:"serve_plain_dns"`
}

TlsConfig

Jump to

Keyboard shortcuts

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