Skip to content

Commit

Permalink
Simplify logic for sni and tcp load balancers
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Aug 26, 2024
1 parent 23a5184 commit cf234a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func GetOpenPort(addr string, port uint32, state *State, sshConn *SSHConnection,
checkedPort, err := CheckPort(checkerPort, viper.GetString("port-bind-range"))
_, ok := state.TCPListeners.Load(listenAddr)

if err == nil && (!viper.GetBool("tcp-load-balancer") || (viper.GetBool("tcp-load-balancer") && !ok) || (sniProxyEnabled && !ok)) {
if err == nil && !ok && (viper.GetBool("tcp-load-balancer") || viper.GetBool("sni-load-balancer")) {
ln, listenErr := Listen(listenAddr)
if listenErr != nil {
err = listenErr
Expand All @@ -720,7 +720,7 @@ func GetOpenPort(addr string, port uint32, state *State, sshConn *SSHConnection,

listenAddr = GenerateAddress(bindAddr, bindPort)
holder, ok := state.TCPListeners.Load(listenAddr)
if ok && (!sniProxyEnabled && viper.GetBool("tcp-load-balancer") || (sniProxyEnabled && viper.GetBool("sni-load-balancer"))) {
if ok && ((!sniProxyEnabled && viper.GetBool("tcp-load-balancer")) || sniProxyEnabled) {
tH = holder
ok = false
}
Expand Down

0 comments on commit cf234a1

Please sign in to comment.