From 133bb2319f15a1a5d945b58d4ac9a32e547756dc Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+dreamacro@users.noreply.github.com> Date: Mon, 4 Jul 2022 21:36:33 +0800 Subject: [PATCH] Chore: load balance hash need to have fallback strategy --- adapter/outboundgroup/loadbalance.go | 6 ++---- go.mod | 2 +- go.sum | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/adapter/outboundgroup/loadbalance.go b/adapter/outboundgroup/loadbalance.go index 6d544a5d..430aed82 100644 --- a/adapter/outboundgroup/loadbalance.go +++ b/adapter/outboundgroup/loadbalance.go @@ -29,10 +29,8 @@ type LoadBalance struct { var errStrategy = errors.New("unsupported strategy") func parseStrategy(config map[string]any) string { - if elm, ok := config["strategy"]; ok { - if strategy, ok := elm.(string); ok { - return strategy - } + if strategy, ok := config["strategy"].(string); ok { + return strategy } return "consistent-hashing" } diff --git a/go.mod b/go.mod index 81cf747a..144abfd1 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.18 require ( github.com/coreos/go-iptables v0.6.0 + github.com/database64128/tfo-go v1.1.0 github.com/dlclark/regexp2 v1.4.0 github.com/go-chi/chi/v5 v5.0.7 github.com/go-chi/cors v1.2.1 @@ -46,7 +47,6 @@ replace github.com/lucas-clemente/quic-go => github.com/tobyxdd/quic-go v0.28.1- require ( github.com/cheekybits/genny v1.0.0 // indirect - github.com/database64128/tfo-go v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect diff --git a/go.sum b/go.sum index 45d99639..131576c4 100644 --- a/go.sum +++ b/go.sum @@ -334,8 +334,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI4N6/rdy1iusx77G3oU= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e h1:NHvCuwuS43lGnYhten69ZWqi2QOj/CiDNcKbVqwVoew= golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=