internal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 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 AddrInfo

type AddrInfo struct {
	IPv4 string
	IPv6 string
}

AddrInfo represents the ip addresses of the host

func GetAddrInfo

func GetAddrInfo(ipv4 bool, ipv6 bool) (*AddrInfo, error)

GetAddrInfo retrieves an AddrInfo instance

type Cache

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

Cache represents a cache for storing CacheEntries.

func NewCache

func NewCache(location string, timeout time.Duration) (*Cache, error)

NewCache returns a new cache struct with a specified location and timeout. When the location is an empty string it will set the cache location to the user cache dir.

func (*Cache) GetIPv4

func (c *Cache) GetIPv4(domain, host string) string

GetIPv4 returns the ipv4 address of a specified domain and host. If this ipv4 address is not present in the cache it will return an empty string.

func (*Cache) GetIPv6

func (c *Cache) GetIPv6(domain, host string) string

GetIPv6 returns the ipv6 address of a specified domain and host. If this ipv6 address is not present in the cache it will return an empty string.

func (*Cache) Load

func (c *Cache) Load() error

Load loads the cache from its location. When there is no file at the cache location it will do nothing. If the last modification to the file was made before the cache timeout it will ignore the file content.

func (*Cache) SetIPv4

func (c *Cache) SetIPv4(domain, host, ipv4 string)

SetIPv4 sets the ipv4 address for a specified domain and host to a specified ipv4 address.

func (*Cache) SetIPv6

func (c *Cache) SetIPv6(domain, host, ipv6 string)

SetIPv6 sets the ipv6 address for a specified domain and host to a specified ipv6 address.

func (*Cache) Store

func (c *Cache) Store() error

Store stores the cache to its location on the disk. If the cache location does not exist it will create the necessary file.

type CacheEntry

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

CacheEntry represents a cache entry.

type Config

type Config struct {
	CustomerNumber int      `yaml:"CUSTOMERNR"`
	APIKey         string   `yaml:"APIKEY"`
	APIPassword    string   `yaml:"APIPASSWORD"`
	IPCache        string   `yaml:"IP-CACHE"`
	IPCacheTimeout int      `yaml:"IP-CACHE-TIMEOUT"`
	Domains        []Domain `yaml:"DOMAINS"`
}

Config represents a config.

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig returns a config loaded from a specified location. It will return an error if there is no file in the specified location or it is unable to read it.

func (*Config) CacheEnabled

func (c *Config) CacheEnabled() bool

CacheEnabled returns whether the cache is enabled in the configuration.

func (*Config) IPv4Enabled

func (c *Config) IPv4Enabled() bool

IPv4Enabled returns true if at least one domain needs the A record configured.

func (*Config) IPv6Enabled

func (c *Config) IPv6Enabled() bool

IPv6Enabled returns true if at least one domain needs the AAAA record configured.

type DNSConfiguratorService

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

DNSConfiguratorService represents a service that will update the DNS records for a given netcup account

func NewDNSConfigurator

func NewDNSConfigurator(config *Config, cache *Cache, logger *Logger) *DNSConfiguratorService

NewDNSConfigurator returns a DNSConfiguratorService by given config, cache and logger

func (*DNSConfiguratorService) Configure

func (dnsc *DNSConfiguratorService) Configure()

Configure will configure the DNS Zones and Records in a netcup account as specified by the config

type Domain

type Domain struct {
	Name  string   `yaml:"NAME"`
	IPv6  bool     `yaml:"IPV6"`
	IPv4  bool     `yaml:"IPV4"`
	TTL   int      `yaml:"TTL"`
	Hosts []string `yaml:"HOSTS"`
}

Domain represents a domain.

func (*Domain) UnmarshalYAML

func (d *Domain) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is implemented to override the default value of the IPv4 field of a Domain with true.

type Logger

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

Logger represents an logger instance

func NewLogger

func NewLogger(verbose bool) *Logger

NewLogger creates a Logger instance with given verboseness

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error will log an error message and exit

func (*Logger) Info

func (l *Logger) Info(msg string, v ...interface{})

Info logs a info message which will only show when verbose is set

func (*Logger) Warning

func (l *Logger) Warning(msg string, v ...interface{})

Warning will log a warning message

Jump to

Keyboard shortcuts

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