fix proxy protocol

This commit is contained in:
ginuerzh
2022-09-28 11:47:56 +08:00
parent cf20abf656
commit a1255e52d8
41 changed files with 524 additions and 180 deletions

View File

@ -35,6 +35,7 @@ const (
mdKeyProxyProtocol = "proxyProtocol"
mdKeyInterface = "interface"
mdKeySoMark = "so_mark"
mdKeyHash = "hash"
)
func ParseAuther(cfg *config.AutherConfig) auth.Authenticator {
@ -120,6 +121,8 @@ func parseChainSelector(cfg *config.SelectorConfig) selector.Selector[chain.Chai
strategy = xs.RandomStrategy[chain.Chainer]()
case "fifo", "ha":
strategy = xs.FIFOStrategy[chain.Chainer]()
case "hash":
strategy = xs.HashStrategy[chain.Chainer]()
default:
strategy = xs.RoundRobinStrategy[chain.Chainer]()
}
@ -143,6 +146,8 @@ func parseNodeSelector(cfg *config.SelectorConfig) selector.Selector[*chain.Node
strategy = xs.RandomStrategy[*chain.Node]()
case "fifo", "ha":
strategy = xs.FIFOStrategy[*chain.Node]()
case "hash":
strategy = xs.HashStrategy[*chain.Node]()
default:
strategy = xs.RoundRobinStrategy[*chain.Node]()
}

View File

@ -20,6 +20,7 @@ import (
tls_util "github.com/go-gost/x/internal/util/tls"
"github.com/go-gost/x/metadata"
"github.com/go-gost/x/registry"
xservice "github.com/go-gost/x/service"
)
func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
@ -200,9 +201,9 @@ func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
return nil, err
}
s := service.NewService(cfg.Name, ln, h,
service.AdmissionOption(admission.AdmissionGroup(admissions...)),
service.LoggerOption(serviceLogger),
s := xservice.NewService(cfg.Name, ln, h,
xservice.AdmissionOption(admission.AdmissionGroup(admissions...)),
xservice.LoggerOption(serviceLogger),
)
serviceLogger.Infof("listening on %s/%s", s.Addr().String(), s.Addr().Network())