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

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

func InitServerCfg

func InitServerCfg(cfg *ServerCommonConf)

func LoadAllConfFromIni

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

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

func RenderContent

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

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

func (*BaseProxyConf) UnmarshalFromIni

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

func (*BaseProxyConf) UnmarshalFromMsg

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

type BaseVisitorConf

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

func (cfg *BaseVisitorConf) GetBaseInfo() *BaseVisitorConf

func (*BaseVisitorConf) UnmarshalFromIni

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

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

func (*BindInfoConf) UnmarshalFromIni

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

func (*BindInfoConf) UnmarshalFromMsg

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

func GetDefaultClientConf() *ClientCommonConf

func UnmarshalClientConfFromIni

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

func (*ClientCommonConf) Check

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

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

func (*DomainConf) UnmarshalFromIni

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

func (*DomainConf) UnmarshalFromMsg

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

type HealthCheckConf

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

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

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

func (*HttpProxyConf) CheckForSvr

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

func (*HttpProxyConf) Compare

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

func (*HttpProxyConf) MarshalToMsg

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

func (*HttpProxyConf) UnmarshalFromIni

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

func (*HttpProxyConf) UnmarshalFromMsg

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

type HttpsProxyConf

type HttpsProxyConf struct {
	BaseProxyConf
	DomainConf
}

HTTPS

func (*HttpsProxyConf) CheckForCli

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

func (*HttpsProxyConf) CheckForSvr

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

func (*HttpsProxyConf) Compare

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

func (*HttpsProxyConf) MarshalToMsg

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

func (*HttpsProxyConf) UnmarshalFromIni

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

func (*HttpsProxyConf) UnmarshalFromMsg

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

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

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

func NewProxyConfFromMsg

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

func GetDefaultServerConf() *ServerCommonConf

func UnmarshalServerConfFromIni

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

func (*ServerCommonConf) Check

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

type StcpProxyConf

type StcpProxyConf struct {
	BaseProxyConf

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

STCP

func (*StcpProxyConf) CheckForCli

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

func (*StcpProxyConf) CheckForSvr

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

func (*StcpProxyConf) Compare

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

func (*StcpProxyConf) MarshalToMsg

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

func (*StcpProxyConf) UnmarshalFromIni

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

func (*StcpProxyConf) UnmarshalFromMsg

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

Only for role server.

type StcpVisitorConf

type StcpVisitorConf struct {
	BaseVisitorConf
}

func (*StcpVisitorConf) Check

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

func (*StcpVisitorConf) Compare

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

func (*StcpVisitorConf) UnmarshalFromIni

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

type TcpProxyConf

type TcpProxyConf struct {
	BaseProxyConf
	BindInfoConf
}

TCP

func (*TcpProxyConf) CheckForCli

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

func (*TcpProxyConf) CheckForSvr

func (cfg *TcpProxyConf) CheckForSvr() error

func (*TcpProxyConf) Compare

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

func (*TcpProxyConf) MarshalToMsg

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

func (*TcpProxyConf) UnmarshalFromIni

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

func (*TcpProxyConf) UnmarshalFromMsg

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

type UdpProxyConf

type UdpProxyConf struct {
	BaseProxyConf
	BindInfoConf
}

UDP

func (*UdpProxyConf) CheckForCli

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

func (*UdpProxyConf) CheckForSvr

func (cfg *UdpProxyConf) CheckForSvr() error

func (*UdpProxyConf) Compare

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

func (*UdpProxyConf) MarshalToMsg

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

func (*UdpProxyConf) UnmarshalFromIni

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

func (*UdpProxyConf) UnmarshalFromMsg

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

type Values

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

func GetValues

func GetValues() *Values

type VisitorConf

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

func NewVisitorConfByType

func NewVisitorConfByType(cfgType string) VisitorConf

func NewVisitorConfFromIni

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

type XtcpProxyConf

type XtcpProxyConf struct {
	BaseProxyConf

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

XTCP

func (*XtcpProxyConf) CheckForCli

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

func (*XtcpProxyConf) CheckForSvr

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

func (*XtcpProxyConf) Compare

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

func (*XtcpProxyConf) MarshalToMsg

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

func (*XtcpProxyConf) UnmarshalFromIni

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

func (*XtcpProxyConf) UnmarshalFromMsg

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

Only for role server.

type XtcpVisitorConf

type XtcpVisitorConf struct {
	BaseVisitorConf
}

func (*XtcpVisitorConf) Check

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

func (*XtcpVisitorConf) Compare

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

func (*XtcpVisitorConf) UnmarshalFromIni

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