config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBTypeMySQL      dbType = "mysql"
	DBTypePostgreSQL dbType = "postgresql"
	DBTypeSQLite3    dbType = "sqlite3"
	DBTypeSQLServer  dbType = "sqlserver"
)
View Source
const DEFAULT_ADMIN_USERNAME = "admin"

Variables

This section is empty.

Functions

func InitDNS

func InitDNS(conf *ConfigGo)

func InitLog

func InitLog(conf *ConfigGo)

Types

type ClientGo

type ClientGo struct {
	Port      uint16
	HTTPPort  uint16
	RedirPort uint16
	Server    string
	Username  string
	Password  string
	ProxyAll  bool
}

type ClientTOML

type ClientTOML struct {
	Port      int    `mapstructure:"port" toml:"port" validate:"numeric,gte=0,lte=65535,required,nefield=HTTPPort"`
	HTTPPort  int    `mapstructure:"http_port" toml:"http_port" validate:"numeric,gte=0,lte=65535,required,nefield=RedirPort"`
	RedirPort int    `mapstructure:"redir_port" toml:"redir_port" validate:"numeric,gte=0,lte=65535,required,nefield=Port"`
	Server    string `mapstructure:"server"  toml:"server" validate:"hostname,required"`
	Username  string `mapstructure:"username" toml:"username" validate:"required"`
	Password  string `mapstructure:"password" toml:"password" validate:"required"`
	ProxyAll  bool   `mapstructure:"proxy_all" toml:"proxy_all"`
}

func (*ClientTOML) Init

func (ct *ClientTOML) Init() (cg *ClientGo, err error)

type ConfigGo

type ConfigGo struct {
	Log    *LogGo    //client,server
	DNS    *DNSGo    //client,server
	Client *ClientGo //client
	Server *serverGo //server
	DB     *dbGo     //server
	// contains filtered or unexported fields
}

func NewConf

func NewConf() *ConfigGo

func NewConfClient

func NewConfClient() (conf *ConfigGo, err error)

func NewConfServer

func NewConfServer() (conf *ConfigGo, err error)

func (*ConfigGo) InitClient

func (conf *ConfigGo) InitClient() error

func (*ConfigGo) SaveClient

func (conf *ConfigGo) SaveClient(filename string) error

type ConfigTOML

type ConfigTOML struct {
	Log    *LogTOML    `mapstructure:"log" toml:"log" validate:"required"`
	DNS    *DNSToml    `mapstructure:"dns" toml:"dns" validate:"required"`
	Client *ClientTOML `mapstructure:"client" toml:"client" validate:"-"`
	Server *ServerTOML `mapstructure:"server" toml:"server" validate:"-"`
	DB     *DBToml     `mapstructure:"db" toml:"db" validate:"-"`
}

ConfigTOML is the struct mapped from the configuration file

func (*ConfigTOML) Init

func (mc *ConfigTOML) Init() (cg *ConfigGo, err error)

type DBToml

type DBToml struct {
	Type     string `mapstructure:"type"  toml:"type" validate:"required"`
	Username string `mapstructure:"username"  toml:"username" validate:"required"`
	Password string `mapstructure:"password"  toml:"password" validate:"required"`
	Host     string `mapstructure:"host"  toml:"host" validate:"required"`
	Port     int    `mapstructure:"port"  toml:"port" validate:"required"`
	Database string `mapstructure:"database"  toml:"database" validate:"required"`
}

func (*DBToml) Init

func (dbt *DBToml) Init() (dbg *dbGo, err error)

type DNSGo

type DNSGo struct {
	Type   DNSType
	Server string
	Addr   net.Addr
}

type DNSToml

type DNSToml struct {
	Type   string `mapstructure:"type" toml:"type" validate:"oneof='default' 'dot' 'doh',required"`
	Server string `mapstructure:"server" toml:"server" validate:"omitempty,required,hostname|hostname_rfc1123|fqdn,required"`
	Addr   string `mapstructure:"addr" toml:"addr" validate:"omitempty,required,ip|ip_addr|tcp_addr|udp_addr,required"`
}

func (*DNSToml) Init

func (dnst *DNSToml) Init() (dnsg *DNSGo, err error)

type DNSType

type DNSType string
const (
	DNSTypeDefault DNSType = "default"
	DNSTypeDoT     DNSType = "dot"
	DNSTypeDoH     DNSType = "doh"
)

type LogGo

type LogGo struct {
	File  *os.File
	Level log.Level
}

type LogTOML

type LogTOML struct {
	File  string `mapstructure:"file" toml:"file"  validate:"required"`
	Level string `mapstructure:"level" toml:"level"  validate:"required,oneof=panic fatal error warn info debug trace "`
}

func (*LogTOML) Init

func (lt *LogTOML) Init() (lg *LogGo, err error)

type ServerTOML

type ServerTOML struct {
	Port          int    `mapstructure:"port" toml:"port" validate:"numeric,gte=0,lte=65535,required"`
	AdminPassword string `mapstructure:"admin_password" toml:"pretend" validate:"required"`
}

func (*ServerTOML) Init

func (st *ServerTOML) Init() (sg *serverGo, err error)

Jump to

Keyboard shortcuts

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