Documentation ¶
Index ¶
- Variables
- func ListenAndServePProf(addr string, handler http.Handler)
- func LoadClientConfig(configFilePath string)
- func LoadServerJsonConfig(config string)
- func StartNetworkService()
- func StopNetworkService()
- type CertificateConfig
- type Client
- type ClientConfig
- type HostInfo
- type Http
- func (self *Http) ActiveClientInfos(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) AddDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) AddProxyClient(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) BestClients(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) ClientInfos(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) DelDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) DeleteProxyClient(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) DomainInfos(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) ProxyInfos(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) RouterInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) Run()
- func (self *Http) Statistics(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (self *Http) UpdateDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) UpdateProxyClient(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
- func (self *Http) WriteJsonInterface(w http.ResponseWriter, data interface{})
- func (self *Http) WriteJsonString(w http.ResponseWriter, str string)
- type HttpsServer
- type LbNode
- type ReverseProxy
- func (this *ReverseProxy) AddDomainConfig(domain string) bool
- func (this *ReverseProxy) AddProxyClient(domain, hostip, port, httsSwitch, httpSwitch string) int
- func (this *ReverseProxy) BeginHttpStatistics()
- func (this *ReverseProxy) ChangeSwitchStatus(domain, protocol, switchStatus string)
- func (this *ReverseProxy) DeleteDomainConig(domain string) bool
- func (this *ReverseProxy) DeleteProxyClient(domain, hostip, port string) bool
- func (this *ReverseProxy) DomainInfos() []string
- func (this *ReverseProxy) GetDomainHostList(domain string) []*HostInfo
- func (this *ReverseProxy) LoadCertificateConfig(certificateConfigFile string)
- func (this *ReverseProxy) LoadProxyConfig(proxyConfigFile string)
- func (this *ReverseProxy) SaveToFile() bool
- func (self *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (this *ReverseProxy) StartAllHttpService() bool
- func (this *ReverseProxy) StartAllHttpsService() bool
- func (self *ReverseProxy) StartProxyServer()
- func (this *ReverseProxy) StopAllHttpsService() bool
- func (this *ReverseProxy) StoptAllHttpService() bool
- func (this *ReverseProxy) UpdateDomain(preDomain, updateDomain, httpsSwitch, httpSwitch string) bool
- func (this *ReverseProxy) UpdateProxyClient(...) bool
- type ReverseProxyConfigData
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultReverseProxy = &ReverseProxy{Cfg: &ReverseProxyConfigData{}}
Functions ¶
func ListenAndServePProf ¶
func LoadClientConfig ¶
func LoadClientConfig(configFilePath string)
{ "cluster":"测集群", "router_list":[ "127.0.0.1:8888", "172.16.200.202:8888" ] }
load client json config file
Types ¶
type CertificateConfig ¶
certificate config
type Client ¶
type ClientConfig ¶
type ClientConfig struct { ClusterName string `json:"cluster"` RouterList []string `json:"router_list"` }
client config
var ClientConfigData ClientConfig
type Http ¶
func (*Http) ActiveClientInfos ¶
func (self *Http) ActiveClientInfos(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
Active ClientInfos
func (*Http) AddDomain ¶
func (self *Http) AddDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
func (*Http) AddProxyClient ¶
func (self *Http) AddProxyClient(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*Http) BestClients ¶
func (self *Http) BestClients(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
The highest weight of the server
func (*Http) ClientInfos ¶
func (self *Http) ClientInfos(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
ClientInfos All servers info include active and inactive
func (*Http) DelDomain ¶
func (self *Http) DelDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
func (*Http) DeleteProxyClient ¶
func (self *Http) DeleteProxyClient(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
func (*Http) DomainInfos ¶
func (self *Http) DomainInfos(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
func (*Http) Index ¶
func (self *Http) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
index redirect to static
func (*Http) ProxyInfos ¶
func (self *Http) ProxyInfos(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
Reverse Proxy infp
func (*Http) RouterInfo ¶
func (self *Http) RouterInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
router server info
func (*Http) Statistics ¶
func (self *Http) Statistics(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
statistics
func (*Http) UpdateDomain ¶
func (self *Http) UpdateDomain(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
change proxy domain
func (*Http) UpdateProxyClient ¶
func (self *Http) UpdateProxyClient(w http.ResponseWriter, r *http.Request, prms httprouter.Params)
func (*Http) WriteJsonInterface ¶
func (self *Http) WriteJsonInterface(w http.ResponseWriter, data interface{})
func (*Http) WriteJsonString ¶
func (self *Http) WriteJsonString(w http.ResponseWriter, str string)
type HttpsServer ¶
type HttpsServer struct { http.Server //If GetCertificate is set, the leaf certificate is returned by calling this function. GetCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error) }
https server
func NewHttpsServer ¶
func NewHttpsServer() *HttpsServer
func (*HttpsServer) AddDomainCertificateConfig ¶
func (self *HttpsServer) AddDomainCertificateConfig(config []*CertificateConfig) error
Add the certificate to the tls.Config.Certificates list, and add the domain name mapping
func (*HttpsServer) AddDomainCertificateItem ¶
func (self *HttpsServer) AddDomainCertificateItem(domain, certFile, keyFile string) error
Add the certificate to the tls.Config.Certificates list, and add the domain name mapping
func (*HttpsServer) RunHttpsService ¶
func (self *HttpsServer) RunHttpsService(addr, certFile, keyFile string, handler http.Handler) error
Start the https server If the two parameters certFile and keyFile are empty, you must call the addDomainCertificate function or the addDomainCertificate function to add a list of digital certificates to multiple certificates list
type LbNode ¶
type LbNode struct { Domain string `json:"domain"` HttpsSwitch string `json:"https_switch"` HttpSwitch string `json:"http_switch"` Clients []*HostInfo `json:"clients"` }
Load Balance Node
type ReverseProxy ¶
type ReverseProxy struct { DomainHostList cache.Cacher Cfg *ReverseProxyConfigData //certificate config CertificateConfigData []*CertificateConfig ProxyCongfigFile string ProxyMethod string // contains filtered or unexported fields }
reverse proxy handler
func (*ReverseProxy) AddDomainConfig ¶
func (this *ReverseProxy) AddDomainConfig(domain string) bool
Add the domain name to the configuration
func (*ReverseProxy) AddProxyClient ¶
func (this *ReverseProxy) AddProxyClient(domain, hostip, port, httsSwitch, httpSwitch string) int
Add the reverse proxy client to the specified domain name Return Value -1 Repeat
0 Failure 1 Success
func (*ReverseProxy) BeginHttpStatistics ¶
func (this *ReverseProxy) BeginHttpStatistics()
Run the http statistics service
func (*ReverseProxy) ChangeSwitchStatus ¶
func (this *ReverseProxy) ChangeSwitchStatus(domain, protocol, switchStatus string)
func (*ReverseProxy) DeleteDomainConig ¶
func (this *ReverseProxy) DeleteDomainConig(domain string) bool
Delete the domain name and sync to the configuration file
func (*ReverseProxy) DeleteProxyClient ¶
func (this *ReverseProxy) DeleteProxyClient(domain, hostip, port string) bool
delete reverse proxydomain
func (*ReverseProxy) GetDomainHostList ¶
func (this *ReverseProxy) GetDomainHostList(domain string) []*HostInfo
hostlist by domain
func (*ReverseProxy) LoadCertificateConfig ¶
func (this *ReverseProxy) LoadCertificateConfig(certificateConfigFile string)
Load Certificate Config
func (*ReverseProxy) LoadProxyConfig ¶
func (this *ReverseProxy) LoadProxyConfig(proxyConfigFile string)
Load proxy config
func (*ReverseProxy) ServeHTTP ¶
func (self *ReverseProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
Http and Https reverse proxy handeler
func (*ReverseProxy) StartAllHttpService ¶
func (this *ReverseProxy) StartAllHttpService() bool
start all http service
func (*ReverseProxy) StartAllHttpsService ¶
func (this *ReverseProxy) StartAllHttpsService() bool
start all https service
func (*ReverseProxy) StartProxyServer ¶
func (self *ReverseProxy) StartProxyServer()
Run Reverse Proxy
func (*ReverseProxy) StopAllHttpsService ¶
func (this *ReverseProxy) StopAllHttpsService() bool
stop all https service
func (*ReverseProxy) StoptAllHttpService ¶
func (this *ReverseProxy) StoptAllHttpService() bool
stop all http service
func (*ReverseProxy) UpdateDomain ¶
func (this *ReverseProxy) UpdateDomain(preDomain, updateDomain, httpsSwitch, httpSwitch string) bool
update domain
func (*ReverseProxy) UpdateProxyClient ¶
func (this *ReverseProxy) UpdateProxyClient(domain, preHost, prePort, updateHost, updatePort, httpsSwitch, httpSwitch string) bool
Update Reverse Proxy Client Info
type ReverseProxyConfigData ¶
type ReverseProxyConfigData struct { ProxyMethod string `json:"proxy_method"` HttpProxyAddr string `json:"http_proxy_addr"` //global http switch GlobalHttpSwitch string `json:"http_switch"` //global https switch GlobalHttpsSwitch string `json:"https_switch"` HttpsProxyAddr string `json:"https_proxy_addr"` ReverseProxy []*LbNode `json:"reserve_proxy"` DomainProxySwitch map[string]map[string]string `json:"-"` }
ReverseProxy Config
type Server ¶
type Server struct { Host string Port string TaskFlag chan bool //syn channel ListenSocket net.Listener //conn }
Router server infomational encapsulation
func (*Server) StopServer ¶
func (self *Server) StopServer()
Send Service Stop Message We Shoule Close all connections before stopping the server。
type ServerConfig ¶
type ServerConfig struct { Host string `json:"host"` Port string `json:"port"` ServerMode string `json:"srvmode"` HttpHost string `json:"httphost"` HttpPort string `json:"httpport"` }
server config mapping struct
var ServerConfigData ServerConfig
server config