config

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitServerCfg added in v0.17.0

func InitServerCfg(cfg *ServerCommonConf)

func LoadProxyConfFromIni added in v0.17.0

func LoadProxyConfFromIni(prefix string, conf ini.File, startProxy map[string]struct{}) (
	proxyConfs map[string]ProxyConf, visitorConfs map[string]ProxyConf, 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)

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"`
}

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 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 HttpProxyConf

type HttpProxyConf struct {
	BaseProxyConf
	DomainConf

	LocalSvrConf

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

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

	LocalSvrConf
}

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"`
	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"`
	AuthTimeout   int64  `json:"auth_timeout"`
	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"`

	// used in role server
	LocalSvrConf

	// used in role visitor
	ServerName string `json:"server_name"`
	BindAddr   string `json:"bind_addr"`
	BindPort   int    `json:"bind_port"`
}

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 TcpProxyConf

type TcpProxyConf struct {
	BaseProxyConf
	BindInfoConf

	LocalSvrConf
}

TCP

func (*TcpProxyConf) CheckForCli added in v0.17.0

func (cfg *TcpProxyConf) CheckForCli() 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

	LocalSvrConf
}

UDP

func (*UdpProxyConf) CheckForCli added in v0.17.0

func (cfg *UdpProxyConf) CheckForCli() 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 XtcpProxyConf added in v0.14.0

type XtcpProxyConf struct {
	BaseProxyConf

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

	// used in role server
	LocalSvrConf

	// used in role visitor
	ServerName string `json:"server_name"`
	BindAddr   string `json:"bind_addr"`
	BindPort   int    `json:"bind_port"`
}

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.

Jump to

Keyboard shortcuts

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