config

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IntervalMinValue is the lowest possible value between two updates (in sec)
	IntervalMinValue = 60
)

Variables

View Source
var (
	// DefaultIPv4Config is the default configuration for IPv4
	DefaultIPv4Config = IPConfig{
		URL:     "https://api.ipify.org",
		Enabled: true,
	}

	// DefaultIPv6Config is the default configuration for IPv6
	DefaultIPv6Config = IPConfig{
		URL:     "https://api6.ipify.org",
		Enabled: false,
	}

	// DefaultScalewayConfig is the default configuration to use the Scaleway API
	DefaultScalewayConfig = ScalewayConfig{}

	// DefaultDomainConfig is the default domain configuration for common parameters
	DefaultDomainConfig = DomainConfig{
		Record: "ddns",
		TTL:    60,
	}

	// DefaultTelegramConfig is the default configuration to use Telegram notifications
	DefaultTelegramConfig = TelegramConfig{
		Enabled:  false,
		Template: "DNS record *{{ .RecordName }}.{{ .Domain }}* has been updated from *{{ .PreviousIP }}* to *{{ .NewIP }}*",
	}

	// DefaultConfig is the global default configuration.
	DefaultConfig = Config{
		Interval:       300,
		DomainConfig:   DefaultDomainConfig,
		IPv4Config:     DefaultIPv4Config,
		IPv6Config:     DefaultIPv6Config,
		ScalewayConfig: DefaultScalewayConfig,
		TelegramConfig: DefaultTelegramConfig,
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval       uint           `yaml:"interval"`
	IPv4Config     IPConfig       `yaml:"ipv4"`
	IPv6Config     IPConfig       `yaml:"ipv6"`
	ScalewayConfig ScalewayConfig `yaml:"scaleway"`
	DomainConfig   DomainConfig   `yaml:"domain"`
	TelegramConfig TelegramConfig `yaml:"telegram"`
}

Config struct for the configuration file

func NewConfig

func NewConfig(path string) (*Config, error)

NewConfig returns a new config object if the file exists

type Container added in v0.1.0

type Container struct {
	Logger    *logrus.Logger
	Config    *Config
	DNS       *scaleway.DNS
	Notifiers []Notifier
}

Container structure to hold global objects

func NewContainer added in v0.1.0

func NewContainer(
	logger *logrus.Logger,
	config *Config,
	dns *scaleway.DNS,

) *Container

NewContainer returns a new container instance

func (*Container) AddNotifier added in v0.1.0

func (c *Container) AddNotifier(notifier Notifier)

AddNotifier adds a new notifier into the container

type DomainConfig

type DomainConfig struct {
	Name   string `yaml:"name"`
	Record string `yaml:"record"`
	TTL    uint32 `yaml:"ttl"`
}

DomainConfig struct for the domain parameters

type IPConfig

type IPConfig struct {
	URL     string `yaml:"url"`
	Enabled bool   `yaml:"enabled"`
}

IPConfig struct for the required configuration for IPv4 or IPv6

type Notifier added in v0.1.0

type Notifier interface {
	Notify(domain string, recordName string, recordType string, previousIP string, newIP string) error
}

Notifier interface to represent any notifier

type ScalewayConfig

type ScalewayConfig struct {
	ProjectID string `yaml:"project_id"`
	AccessKey string `yaml:"access_key"`
	SecretKey string `yaml:"secret_key"`
}

ScalewayConfig struct for the required configuration to use the Scaleway API

type TelegramConfig added in v0.1.0

type TelegramConfig struct {
	Enabled  bool   `yaml:"enabled"`
	Token    string `yaml:"token"`
	ChatID   int64  `yaml:"chat_id"`
	Template string `yaml:"template"`
}

TelegramConfig struct for Telegram notifications after updates

Jump to

Keyboard shortcuts

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