config

package
v0.0.0-...-f116871 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	CfgFilePath        string                 `json:"-"`
	Reloaded           chan bool              `json:"-"`              // A channel upon which config reload events are delivered
	LastUpdateInterval string                 `json:"-"`              // Used to track changes to the update interval
	FileInfo           os.FileInfo            `json:"-"`              // Used to track changes to the config file
	Mu                 *sync.Mutex            `json:"-"`              // Used to lock and unlock access to the package level cfg
	UpdateInterval     string                 `json:"updateInterval"` // A duration string parsed by time.ParseDuration
	ServerPort         string                 `json:"serverPort"`     // The port that the inbuilt http server listens on
	Hostname           string                 `json:"hostname"`       // The hostname of the machine where this code is running
	LastIPv4           net.IP                 `json:"lastIPv4"`
	LastIPv6           net.IP                 `json:"lastIPv6"`
	Router             RouterConfiguration    `json:"router,omitempty"`
	Services           []ServiceConfiguration `json:"services,omitempty"`
	Notifications      Notifications          `json:"notifications,omitempty"`
}

func Load

func Load(cfgFilePath string) (*Configuration, *time.Ticker)

Load loads the serviceConfig.json file described by cfgFilePath and sets up a config file watcher to detect changes to enable config reload on change. Load also creates a new Time.Ticker with a tick duration set to the currently configured appData.UpdateInterval

func (*Configuration) GetDomainsStr

func (appData *Configuration) GetDomainsStr() (string, error)

GetDomainsStr returns a comma separated string of all configured target domain names

func (*Configuration) IPAddressesChanged

func (appData *Configuration) IPAddressesChanged(ipv4 net.IP, ipv6 net.IP) bool

IPAddressesChanged returns an indicator that describes if either the supplied ipv4 or ipv6 have changed

func (*Configuration) Save

func (appData *Configuration) Save(ipv4 net.IP, ipv6 net.IP) error

Save persists the serviceConfig.json file to the file system with the supplied currentPublicIpAddr

type Email

type Email struct {
	IsEnabled    bool   `json:"enabled"`
	Username     string `json:"username,omitempty"`
	Password     string `json:"password,omitempty"`
	From         EmailAddress
	Recipients   []EmailAddress
	SmtpServer   string `json:"smtpServer,omitempty"`
	SecurityType string `json:"securityType,omitempty"` /*SSL or TLS*/
}

type EmailAddress

type EmailAddress struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
}

type Notifications

type Notifications struct {
	SipgateSMS SipgateSMS `json:"sipgateSMS,omitempty"`
	Email      Email      `json:"email,omitempty"`
}

type RouterConfiguration

type RouterConfiguration struct {
	RouterType   string `json:"routerType,omitempty"`
	Username     string `json:"userName,omitempty"`
	Password     string `json:"password,omitempty"`
	LoginUrl     string `json:"loginUrl,omitempty"`
	IpDetailsUrl string `json:"ipDetailsUrl,omitempty"`
}

type ServiceConfiguration

type ServiceConfiguration struct {
	ServiceType  string `json:"serviceType"`
	TargetDomain string `json:"targetDomain"`
	Username     string `json:"username,omitempty"`
	Password     string `json:"password,omitempty"`
	Token        string `json:"token,omitempty"`
	EmailAddress string `json:"emailAddress,omitempty"`
	APIKey       string `json:"apikey,omitempty"`
	APISecret    string `json:"apisecret,omitempty"`
	RecordName   string `json:"recordname,omitempty"`
	Port         int    `json:"port,omitempty"`
	TTL          int    `json:"ttl,omitempty"`
}

type SipgateSMS

type SipgateSMS struct {
	Enabled   bool   `json:"enabled"`
	TokenId   string `json:"tokenId,omitempty"`
	Token     string `json:"token,omitempty"`
	SmsId     string `json:"smsId,omitempty"`
	Recipient string `json:"recipient,omitempty"`
}

Jump to

Keyboard shortcuts

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