common

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MMDB_DBIP = iota
	MMDB_MAXMIND
)
View Source
const AppName = "mirrorselect"

Variables

View Source
var Commit = "$Format:%h$"
View Source
var Date = "$Format:%cs$"
View Source
var Version = "$Format:%(describe:tags=true,abbrev=0)$"

Use 'var' instead of 'const' since we may override them via -ldflags.

Functions

func DebugPrintf

func DebugPrintf(format string, v ...interface{})

func ErrorPrintf

func ErrorPrintf(format string, v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func InfoPrintf

func InfoPrintf(format string, v ...interface{})

func WarnPrintf

func WarnPrintf(format string, v ...interface{})

Types

type Config

type Config struct {
	Debug          bool   `mapstructure:"debug"`
	Listen         string `mapstructure:"listen"`
	MirrorListFile string `mapstructure:"mirror_list"`
	Mirrors        map[string]*Mirror
	MMDBType       string `mapstructure:"mmdb_type"`
	MMDBFile       string `mapstructure:"mmdb_file"`
	MMDB           MMDBConfig
	Monitor        MonitorConfig
}
var AppConfig *Config

func ReadConfig

func ReadConfig(cfgfile string) *Config

Read main configurations from file.

type MMDBConfig

type MMDBConfig struct {
	Type int
	DB   *maxminddb.Reader
}

type Mirror

type Mirror struct {
	Name          string       `mapstructure:"name" json:"name"`
	IsDefault     bool         `mapstructure:"default" json:"default"`
	URL           string       `mapstructure:"url" json:"url"`
	ContinentCode string       `mapstructure:"continent_code" json:"continent_code"`
	CountryCode   string       `mapstructure:"country_code" json:"country_code"`
	Latitude      float64      `mapstructure:"latitude" json:"latitude"`
	Longitude     float64      `mapstructure:"longitude" json:"longitude"`
	Status        MirrorStatus `json:"status"`
}

type MirrorStatus

type MirrorStatus struct {
	Online     bool `json:"online"`
	OKCount    int  `json:"ok_count"`
	ErrorCount int  `json:"error_count"`
	Hysteresis int  `json:"hysteresis"`
}

type MonitorConfig

type MonitorConfig struct {
	Workers     int           `mapstructure:"workers"`
	Interval    time.Duration `mapstructure:"interval"`
	Timeout     time.Duration `mapstructure:"timeout"`
	Hysteresis  int           `mapstructure:"hysteresis"`
	TLSVerify   bool          `mapstructure:"tls_verify"`
	UserAgent   string        `mapstructure:"user_agent"`
	NotifyExec  string        `mapstructure:"notify_exec"`
	ExecTimeout time.Duration `mapstructure:"exec_timeout"`
}

Jump to

Keyboard shortcuts

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