configuration

package
v0.0.0-...-a6db137 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinimalReloadSeconds = 60               // one minute
	MaxReloadSeconds     = 2 * 24 * 60 * 60 // two days

	CountryPfxDigits = 3
	// Maximal length of local phone numbers (i.e. w/o country prefix)
	// Numbers which are of this length or shorter will be treated as local numbers.
	LocalPhoneNumberMax = 7
	// Minimal length of local phone numbers (i.e. w/o country prefix)
	// This guarantees that numbers with the minimal length are not assumed to be
	// local numbers even if they have a country prefix.
	LocalPhoneNumberMin = LocalPhoneNumberMax - CountryPfxDigits + 1
)

Variables

This section is empty.

Functions

func ConvertToJSON

func ConvertToJSON(conf Config, censorSensitive bool) ([]byte, error)

func ValidateCountryPrefix

func ValidateCountryPrefix(pfx string) error

func ValidateSources

func ValidateSources(srcs []string) error

func ValidateURL

func ValidateURL(u string) error

func WriteToJSON

func WriteToJSON(conf *Config, path string, censorSensitive bool) error

Types

type Config

type Config struct {
	// Generally applicable.
	Sources         []string `json:"sources"`
	OLSRFile        string   `json:"olsr_file"`
	SysInfoURL      string   `json:"sysinfo_url"`
	Server          bool     `json:"server,omitempty"`
	LDAPServer      bool     `json:"ldap_server"`
	SIPServer       bool     `json:"sip_server"`
	IncludeRoutable bool     `json:"include_routable"`
	CountryPrefix   string   `json:"country_prefix"`

	Debug                       bool `json:"debug"`
	AllowRuntimeConfigChanges   bool `json:"allow_runtime_config_changes"`
	AllowPermanentConfigChanges bool `json:"allow_permanent_config_changes"`

	// Only relevant when running in non-server / ad-hoc mode.
	Path           string   `json:"path"`
	Formats        []string `json:"formats"`
	Targets        []string `json:"targets"`
	Resolve        bool     `json:"resolve"`
	IndicateActive bool     `json:"indicate_active"`
	FilterInactive bool     `json:"filter_inactive"`
	ActivePfx      string   `json:"active_pfx"`

	// Only relevant when running in server mode.
	Port          int           `json:"port"`
	Cache         string        `json:"cache"`
	ReloadSeconds int           `json:"reload_seconds"`
	Reload        time.Duration `json:"-"`
	WebUser       string        `json:"web_user"`
	WebPwd        string        `json:"web_pwd"`
	UpdateURLs    []string      `json:"update_urls"`
	// Only relevant when LDAP server is on.
	LDAPPort int    `json:"ldap_port"`
	LDAPUser string `json:"ldap_user"`
	LDAPPwd  string `json:"ldap_pwd"`
	// Only relevant when SIP server is on.
	SIPPort int `json:"sip_port"`
}

func ReadFromJSON

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

func (*Config) Diff

func (c *Config) Diff(other *Config) (string, error)

func (*Config) GetGlobalNumber

func (c *Config) GetGlobalNumber(pn string) string

func (*Config) GetLocalNumber

func (c *Config) GetLocalNumber(pn string) string

func (*Config) IsLocalNumber

func (c *Config) IsLocalNumber(pn string) bool

func (*Config) IsValid

func (c *Config) IsValid() error

Jump to

Keyboard shortcuts

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