Fix client panic on absent server field

This commit is contained in:
Nikita Mochalov
2023-06-05 15:27:45 +03:00
committed by GitHub
parent 27a8b96ee3
commit f71c49511b

View File

@@ -17,6 +17,7 @@ import (
"bytes"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"math/rand"
"net"
@@ -1949,12 +1950,12 @@ func (c *client) processRouteConnect(srv *Server, arg []byte, lang string) error
c.closeConnection(WrongGateway)
return ErrWrongGateway
}
var perms *RoutePermissions
//TODO this check indicates srv may be nil. see srv usage below
if srv != nil {
perms = srv.getOpts().Cluster.Permissions
if srv == nil {
return errors.New("server is not set")
}
perms := srv.getOpts().Cluster.Permissions
clusterName := srv.ClusterName()
// If we have a cluster name set, make sure it matches ours.