improve http group load balancing (#3131)

This commit is contained in:
fatedier
2022-10-19 12:14:35 +08:00
committed by GitHub
parent 3fbe6b659e
commit cf66ca10b4
5 changed files with 119 additions and 47 deletions

View File

@@ -29,13 +29,18 @@ import (
type RouteInfo string
const (
RouteInfoURL RouteInfo = "url"
RouteInfoHost RouteInfo = "host"
RouteInfoHTTPUser RouteInfo = "httpUser"
RouteInfoRemote RouteInfo = "remote"
RouteInfoURLHost RouteInfo = "urlHost"
RouteInfoKey RouteInfo = "routeInfo"
)
type RequestRouteInfo struct {
URL string
Host string
HTTPUser string
RemoteAddr string
URLHost string
Endpoint string
}
type (
muxFunc func(net.Conn) (net.Conn, map[string]string, error)
httpAuthFunc func(net.Conn, string, string, string) (bool, error)
@@ -75,8 +80,12 @@ func NewMuxer(
return mux, nil
}
type ChooseEndpointFunc func() (string, error)
type CreateConnFunc func(remoteAddr string) (net.Conn, error)
type CreateConnByEndpointFunc func(endpoint, remoteAddr string) (net.Conn, error)
// RouteConfig is the params used to match HTTP requests
type RouteConfig struct {
Domain string
@@ -87,7 +96,9 @@ type RouteConfig struct {
Headers map[string]string
RouteByHTTPUser string
CreateConnFn CreateConnFunc
CreateConnFn CreateConnFunc
ChooseEndpointFn ChooseEndpointFunc
CreateConnByEndpointFn CreateConnByEndpointFunc
}
// listen for a new domain name, if rewriteHost is not empty and rewriteFunc is not nil