config

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRenderedConfFromFile added in v0.23.0

func GetRenderedConfFromFile(path string) (out string, err error)

func InitServerCfg added in v0.17.0

func InitServerCfg(cfg *ServerCommonConf)

func LoadAllConfFromIni added in v0.22.0

func LoadAllConfFromIni(prefix string, content string, startProxy map[string]struct{}) (
	proxyConfs map[string]ProxyConf, visitorConfs map[string]VisitorConf, err error)

if len(startProxy) is 0, start all otherwise just start proxies in startProxy map

func ParseRangeSection added in v0.16.0

func ParseRangeSection(name string, section ini.Section) (sections map[string]ini.Section, err error)

func RenderContent added in v0.23.0

func RenderContent(in string) (out string, err error)

Types

type BaseProxyConf

type BaseProxyConf struct {
	ProxyName string `json:"proxy_name"`
	ProxyType string `json:"proxy_type"`

	UseEncryption  bool   `json:"use_encryption"`
	UseCompression bool   `json:"use_compression"`
	Group          string `json:"group"`
	GroupKey       string `json:"group_key"`

	LocalSvrConf
	HealthCheckConf // only used for client
}

BaseProxy info

func (*BaseProxyConf) GetBaseInfo

func (cfg *BaseProxyConf) GetBaseInfo() *BaseProxyConf

func (*BaseProxyConf) MarshalToMsg added in v0.17.0

func (cfg *BaseProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*BaseProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *BaseProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) error

func (*BaseProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *BaseProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type BaseVisitorConf added in v0.22.0

type BaseVisitorConf struct {
	ProxyName      string `json:"proxy_name"`
	ProxyType      string `json:"proxy_type"`
	UseEncryption  bool   `json:"use_encryption"`
	UseCompression bool   `json:"use_compression"`
	Role           string `json:"role"`
	Sk             string `json:"sk"`
	ServerName     string `json:"server_name"`
	BindAddr       string `json:"bind_addr"`
	BindPort       int    `json:"bind_port"`
}

func (*BaseVisitorConf) GetBaseInfo added in v0.22.0

func (cfg *BaseVisitorConf) GetBaseInfo() *BaseVisitorConf

func (*BaseVisitorConf) UnmarshalFromIni added in v0.22.0

func (cfg *BaseVisitorConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

type BindInfoConf

type BindInfoConf struct {
	RemotePort int `json:"remote_port"`
}

Bind info

func (*BindInfoConf) MarshalToMsg added in v0.17.0

func (cfg *BindInfoConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*BindInfoConf) UnmarshalFromIni added in v0.17.0

func (cfg *BindInfoConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*BindInfoConf) UnmarshalFromMsg added in v0.17.0

func (cfg *BindInfoConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type ClientCommonConf

type ClientCommonConf struct {
	ServerAddr        string              `json:"server_addr"`
	ServerPort        int                 `json:"server_port"`
	HttpProxy         string              `json:"http_proxy"`
	LogFile           string              `json:"log_file"`
	LogWay            string              `json:"log_way"`
	LogLevel          string              `json:"log_level"`
	LogMaxDays        int64               `json:"log_max_days"`
	Token             string              `json:"token"`
	AdminAddr         string              `json:"admin_addr"`
	AdminPort         int                 `json:"admin_port"`
	AdminUser         string              `json:"admin_user"`
	AdminPwd          string              `json:"admin_pwd"`
	PoolCount         int                 `json:"pool_count"`
	TcpMux            bool                `json:"tcp_mux"`
	User              string              `json:"user"`
	DnsServer         string              `json:"dns_server"`
	LoginFailExit     bool                `json:"login_fail_exit"`
	Start             map[string]struct{} `json:"start"`
	Protocol          string              `json:"protocol"`
	HeartBeatInterval int64               `json:"heartbeat_interval"`
	HeartBeatTimeout  int64               `json:"heartbeat_timeout"`
}

client common config

func GetDefaultClientConf added in v0.17.0

func GetDefaultClientConf() *ClientCommonConf

func UnmarshalClientConfFromIni added in v0.17.0

func UnmarshalClientConfFromIni(defaultCfg *ClientCommonConf, content string) (cfg *ClientCommonConf, err error)

func (*ClientCommonConf) Check added in v0.17.0

func (cfg *ClientCommonConf) Check() (err error)

type DomainConf

type DomainConf struct {
	CustomDomains []string `json:"custom_domains"`
	SubDomain     string   `json:"sub_domain"`
}

Domain info

func (*DomainConf) MarshalToMsg added in v0.17.0

func (cfg *DomainConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*DomainConf) UnmarshalFromIni added in v0.17.0

func (cfg *DomainConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*DomainConf) UnmarshalFromMsg added in v0.17.0

func (cfg *DomainConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type HealthCheckConf added in v0.22.0

type HealthCheckConf struct {
	HealthCheckType      string `json:"health_check_type"` // tcp | http
	HealthCheckTimeoutS  int    `json:"health_check_timeout_s"`
	HealthCheckMaxFailed int    `json:"health_check_max_failed"`
	HealthCheckIntervalS int    `json:"health_check_interval_s"`
	HealthCheckUrl       string `json:"health_check_url"`

	// local_ip + local_port
	HealthCheckAddr string `json:"-"`
}

Health check info

func (*HealthCheckConf) UnmarshalFromIni added in v0.22.0

func (cfg *HealthCheckConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

type HttpProxyConf

type HttpProxyConf struct {
	BaseProxyConf
	DomainConf

	Locations         []string          `json:"locations"`
	HttpUser          string            `json:"http_user"`
	HttpPwd           string            `json:"http_pwd"`
	HostHeaderRewrite string            `json:"host_header_rewrite"`
	Headers           map[string]string `json:"headers"`
}

HTTP

func (*HttpProxyConf) CheckForCli added in v0.17.0

func (cfg *HttpProxyConf) CheckForCli() (err error)

func (*HttpProxyConf) CheckForSvr added in v0.17.0

func (cfg *HttpProxyConf) CheckForSvr() (err error)

func (*HttpProxyConf) Compare added in v0.13.0

func (cfg *HttpProxyConf) Compare(cmp ProxyConf) bool

func (*HttpProxyConf) MarshalToMsg added in v0.17.0

func (cfg *HttpProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*HttpProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *HttpProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*HttpProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *HttpProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type HttpsProxyConf

type HttpsProxyConf struct {
	BaseProxyConf
	DomainConf
}

HTTPS

func (*HttpsProxyConf) CheckForCli added in v0.17.0

func (cfg *HttpsProxyConf) CheckForCli() (err error)

func (*HttpsProxyConf) CheckForSvr added in v0.17.0

func (cfg *HttpsProxyConf) CheckForSvr() (err error)

func (*HttpsProxyConf) Compare added in v0.13.0

func (cfg *HttpsProxyConf) Compare(cmp ProxyConf) bool

func (*HttpsProxyConf) MarshalToMsg added in v0.17.0

func (cfg *HttpsProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*HttpsProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *HttpsProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*HttpsProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *HttpsProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type LocalSvrConf

type LocalSvrConf struct {
	LocalIp   string `json:"local_ip"`
	LocalPort int    `json:"local_port"`

	Plugin       string            `json:"plugin"`
	PluginParams map[string]string `json:"plugin_params"`
}

Local service info

func (*LocalSvrConf) UnmarshalFromIni added in v0.17.0

func (cfg *LocalSvrConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

type ProxyConf

type ProxyConf interface {
	GetBaseInfo() *BaseProxyConf
	UnmarshalFromMsg(pMsg *msg.NewProxy)
	UnmarshalFromIni(prefix string, name string, conf ini.Section) error
	MarshalToMsg(pMsg *msg.NewProxy)
	CheckForCli() error
	CheckForSvr() error
	Compare(conf ProxyConf) bool
}

func NewConfByType

func NewConfByType(proxyType string) ProxyConf

NewConfByType creates a empty ProxyConf object by proxyType. If proxyType isn't exist, return nil.

func NewProxyConfFromIni added in v0.17.0

func NewProxyConfFromIni(prefix string, name string, section ini.Section) (cfg ProxyConf, err error)

func NewProxyConfFromMsg added in v0.17.0

func NewProxyConfFromMsg(pMsg *msg.NewProxy) (cfg ProxyConf, err error)

type ServerCommonConf

type ServerCommonConf struct {
	BindAddr      string `json:"bind_addr"`
	BindPort      int    `json:"bind_port"`
	BindUdpPort   int    `json:"bind_udp_port"`
	KcpBindPort   int    `json:"kcp_bind_port"`
	ProxyBindAddr string `json:"proxy_bind_addr"`

	// If VhostHttpPort equals 0, don't listen a public port for http protocol.
	VhostHttpPort int `json:"vhost_http_port"`

	// if VhostHttpsPort equals 0, don't listen a public port for https protocol
	VhostHttpsPort int `json:"vhost_http_port"`

	VhostHttpTimeout int64 `json:"vhost_http_timeout"`

	DashboardAddr string `json:"dashboard_addr"`

	// if DashboardPort equals 0, dashboard is not available
	DashboardPort int    `json:"dashboard_port"`
	DashboardUser string `json:"dashboard_user"`
	DashboardPwd  string `json:"dashboard_pwd"`
	AssetsDir     string `json:"asserts_dir"`
	LogFile       string `json:"log_file"`
	LogWay        string `json:"log_way"` // console or file
	LogLevel      string `json:"log_level"`
	LogMaxDays    int64  `json:"log_max_days"`
	Token         string `json:"token"`
	SubDomainHost string `json:"subdomain_host"`
	TcpMux        bool   `json:"tcp_mux"`

	AllowPorts        map[int]struct{}
	MaxPoolCount      int64 `json:"max_pool_count"`
	MaxPortsPerClient int64 `json:"max_ports_per_client"`
	HeartBeatTimeout  int64 `json:"heart_beat_timeout"`
	UserConnTimeout   int64 `json:"user_conn_timeout"`
}

common config

func GetDefaultServerConf added in v0.17.0

func GetDefaultServerConf() *ServerCommonConf

func UnmarshalServerConfFromIni added in v0.17.0

func UnmarshalServerConfFromIni(defaultCfg *ServerCommonConf, content string) (cfg *ServerCommonConf, err error)

func (*ServerCommonConf) Check added in v0.17.0

func (cfg *ServerCommonConf) Check() (err error)

type StcpProxyConf added in v0.13.0

type StcpProxyConf struct {
	BaseProxyConf

	Role string `json:"role"`
	Sk   string `json:"sk"`
}

STCP

func (*StcpProxyConf) CheckForCli added in v0.17.0

func (cfg *StcpProxyConf) CheckForCli() (err error)

func (*StcpProxyConf) CheckForSvr added in v0.17.0

func (cfg *StcpProxyConf) CheckForSvr() (err error)

func (*StcpProxyConf) Compare added in v0.13.0

func (cfg *StcpProxyConf) Compare(cmp ProxyConf) bool

func (*StcpProxyConf) MarshalToMsg added in v0.17.0

func (cfg *StcpProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*StcpProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *StcpProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*StcpProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *StcpProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

Only for role server.

type StcpVisitorConf added in v0.22.0

type StcpVisitorConf struct {
	BaseVisitorConf
}

func (*StcpVisitorConf) Check added in v0.22.0

func (cfg *StcpVisitorConf) Check() (err error)

func (*StcpVisitorConf) Compare added in v0.22.0

func (cfg *StcpVisitorConf) Compare(cmp VisitorConf) bool

func (*StcpVisitorConf) UnmarshalFromIni added in v0.22.0

func (cfg *StcpVisitorConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

type TcpProxyConf

type TcpProxyConf struct {
	BaseProxyConf
	BindInfoConf
}

TCP

func (*TcpProxyConf) CheckForCli added in v0.17.0

func (cfg *TcpProxyConf) CheckForCli() (err error)

func (*TcpProxyConf) CheckForSvr added in v0.17.0

func (cfg *TcpProxyConf) CheckForSvr() error

func (*TcpProxyConf) Compare added in v0.13.0

func (cfg *TcpProxyConf) Compare(cmp ProxyConf) bool

func (*TcpProxyConf) MarshalToMsg added in v0.17.0

func (cfg *TcpProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*TcpProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *TcpProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*TcpProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *TcpProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type UdpProxyConf

type UdpProxyConf struct {
	BaseProxyConf
	BindInfoConf
}

UDP

func (*UdpProxyConf) CheckForCli added in v0.17.0

func (cfg *UdpProxyConf) CheckForCli() (err error)

func (*UdpProxyConf) CheckForSvr added in v0.17.0

func (cfg *UdpProxyConf) CheckForSvr() error

func (*UdpProxyConf) Compare added in v0.13.0

func (cfg *UdpProxyConf) Compare(cmp ProxyConf) bool

func (*UdpProxyConf) MarshalToMsg added in v0.17.0

func (cfg *UdpProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*UdpProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *UdpProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*UdpProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *UdpProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

type Values added in v0.23.0

type Values struct {
	Envs map[string]string // environment vars
}

func GetValues added in v0.23.0

func GetValues() *Values

type VisitorConf added in v0.22.0

type VisitorConf interface {
	GetBaseInfo() *BaseVisitorConf
	Compare(cmp VisitorConf) bool
	UnmarshalFromIni(prefix string, name string, section ini.Section) error
	Check() error
}

func NewVisitorConfByType added in v0.22.0

func NewVisitorConfByType(cfgType string) VisitorConf

func NewVisitorConfFromIni added in v0.22.0

func NewVisitorConfFromIni(prefix string, name string, section ini.Section) (cfg VisitorConf, err error)

type XtcpProxyConf added in v0.14.0

type XtcpProxyConf struct {
	BaseProxyConf

	Role string `json:"role"`
	Sk   string `json:"sk"`
}

XTCP

func (*XtcpProxyConf) CheckForCli added in v0.17.0

func (cfg *XtcpProxyConf) CheckForCli() (err error)

func (*XtcpProxyConf) CheckForSvr added in v0.17.0

func (cfg *XtcpProxyConf) CheckForSvr() (err error)

func (*XtcpProxyConf) Compare added in v0.14.0

func (cfg *XtcpProxyConf) Compare(cmp ProxyConf) bool

func (*XtcpProxyConf) MarshalToMsg added in v0.17.0

func (cfg *XtcpProxyConf) MarshalToMsg(pMsg *msg.NewProxy)

func (*XtcpProxyConf) UnmarshalFromIni added in v0.17.0

func (cfg *XtcpProxyConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

func (*XtcpProxyConf) UnmarshalFromMsg added in v0.17.0

func (cfg *XtcpProxyConf) UnmarshalFromMsg(pMsg *msg.NewProxy)

Only for role server.

type XtcpVisitorConf added in v0.22.0

type XtcpVisitorConf struct {
	BaseVisitorConf
}

func (*XtcpVisitorConf) Check added in v0.22.0

func (cfg *XtcpVisitorConf) Check() (err error)

func (*XtcpVisitorConf) Compare added in v0.22.0

func (cfg *XtcpVisitorConf) Compare(cmp VisitorConf) bool

func (*XtcpVisitorConf) UnmarshalFromIni added in v0.22.0

func (cfg *XtcpVisitorConf) UnmarshalFromIni(prefix string, name string, section ini.Section) (err error)

Jump to

Keyboard shortcuts

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