new feature: load balancing for tcp proxy

This commit is contained in:
fatedier
2018-05-22 23:59:35 +08:00
parent b9f062bef2
commit f56b49ad3b
6 changed files with 279 additions and 41 deletions

View File

@ -40,38 +40,41 @@ const (
var ServerService *Service
// Server service.
// Server service
type Service struct {
// Dispatch connections to different handlers listen on same port.
// Dispatch connections to different handlers listen on same port
muxer *mux.Mux
// Accept connections from client.
// Accept connections from client
listener frpNet.Listener
// Accept connections using kcp.
// Accept connections using kcp
kcpListener frpNet.Listener
// For https proxies, route requests to different clients by hostname and other infomation.
// For https proxies, route requests to different clients by hostname and other infomation
VhostHttpsMuxer *vhost.HttpsMuxer
httpReverseProxy *vhost.HttpReverseProxy
// Manage all controllers.
// Manage all controllers
ctlManager *ControlManager
// Manage all proxies.
// Manage all proxies
pxyManager *ProxyManager
// Manage all visitor listeners.
// Manage all visitor listeners
visitorManager *VisitorManager
// Manage all tcp ports.
// Manage all tcp ports
tcpPortManager *PortManager
// Manage all udp ports.
// Manage all udp ports
udpPortManager *PortManager
// Controller for nat hole connections.
// Tcp Group Controller
tcpGroupCtl *TcpGroupCtl
// Controller for nat hole connections
natHoleController *NatHoleController
}
@ -84,6 +87,7 @@ func NewService() (svr *Service, err error) {
tcpPortManager: NewPortManager("tcp", cfg.ProxyBindAddr, cfg.AllowPorts),
udpPortManager: NewPortManager("udp", cfg.ProxyBindAddr, cfg.AllowPorts),
}
svr.tcpGroupCtl = NewTcpGroupCtl(svr.tcpPortManager)
// Init assets.
err = assets.Load(cfg.AssetsDir)