Skip to content

Commit

Permalink
resolving CodeQL error
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekhiwarkar committed Aug 26, 2022
1 parent efc2d46 commit e29c898
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pkg/relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func setupserver(log *relaylogger.RelayLog) error {
}
p, _ := strconv.ParseInt(port, 10, 64)
if p > 0 && p <= math.MaxInt32 {
utils.RelayUserPort = int(p)
utils.RelayUserPort = int32(p)
}
if err != nil {
log.Error(
Expand All @@ -209,7 +209,7 @@ func setupserver(log *relaylogger.RelayLog) error {
}
q, _ := strconv.ParseInt(port, 10, 64)
if q > 0 && q <= math.MaxInt32 {
utils.RelayConnectorPort = int(q)
utils.RelayConnectorPort = int32(q)
}
if err != nil {
log.Error(
Expand Down Expand Up @@ -475,7 +475,7 @@ func registerRelayUserServer(ctx context.Context, log *relaylogger.RelayLog) err
}
// this is a server certificate CN is same as ServerHost
cfg.ServerHost = utils.RelayUserHost
cfg.ServerPort = int32(utils.RelayUserPort)
cfg.ServerPort = utils.RelayUserPort
err := prepareConfigCSRForBootStrapOutSideCore(cfg, cfg.ServerHost, log)
if err != nil {
return fmt.Errorf("failed in config csr for relay user server bootstrap")
Expand All @@ -502,7 +502,7 @@ func registerRelayUserServer(ctx context.Context, log *relaylogger.RelayLog) err
utils.RelayUserCert = cfg.Certificate
utils.RelayUserKey = cfg.PrivateKey
utils.RelayUserCACert = cfg.CACertificate
utils.RelayUserPort = int(cfg.ServerPort)
utils.RelayUserPort = cfg.ServerPort
utils.RelayUserHost = cfg.ServerHost

return nil
Expand Down Expand Up @@ -571,7 +571,7 @@ func registerRelayConnectorServer(ctx context.Context, log *relaylogger.RelayLog
}
// this is a server certificate CN is same as ServerHost
cfg.ServerHost = utils.RelayConnectorHost
cfg.ServerPort = int32(utils.RelayConnectorPort)
cfg.ServerPort = utils.RelayConnectorPort
err := prepareConfigCSRForBootStrapOutSideCore(cfg, cfg.ServerHost, log)
if err != nil {
return fmt.Errorf("failed in config csr for relay connector server bootstrap")
Expand Down Expand Up @@ -600,7 +600,7 @@ func registerRelayConnectorServer(ctx context.Context, log *relaylogger.RelayLog
utils.RelayConnectorKey = cfg.PrivateKey
utils.RelayConnectorCACert = cfg.CACertificate
utils.RelayConnectorHost = cfg.ServerHost
utils.RelayConnectorPort = int(cfg.ServerPort)
utils.RelayConnectorPort = cfg.ServerPort

return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ var (
RelayUserCACert []byte

//RelayUserPort user facing seerver port
RelayUserPort int
RelayUserPort int32
// RelayUserHost user facing seerver host (domain)
RelayUserHost string
//RelayConnectorCert used for relay-connector termination
Expand All @@ -227,7 +227,7 @@ var (
// RelayConnectorHost connector facing server host (domain)
RelayConnectorHost string
// RelayConnectorPort connector facing server port
RelayConnectorPort int
RelayConnectorPort int32

// CDRelayUserCert used for client/peer communication
CDRelayUserCert []byte
Expand Down Expand Up @@ -532,7 +532,7 @@ func GetRelayIP() string {
// GetRelayIPPort get relay IP:PORT of user facing server
func GetRelayIPPort() string {
if RelayIPFromConfig == "" {
return GetRelayIP() + ":" + strconv.Itoa(RelayUserPort)
return GetRelayIP() + ":" + strconv.Itoa(int(RelayUserPort))
}
return RelayIPFromConfig
}
Expand Down

0 comments on commit e29c898

Please sign in to comment.