review comments

This commit is contained in:
Matthew R Kasun
2023-01-18 17:41:06 -05:00
parent e77bd39f44
commit 74750ca045

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"github.com/google/uuid"
"github.com/gravitl/netmaker/database"
@@ -326,11 +327,12 @@ func CheckHostPorts(h *models.Host) {
}
for _, host := range hosts {
if host.EndpointIP.Equal(h.EndpointIP) {
if host.ListenPort == h.ListenPort || host.ProxyListenPort == h.ProxyListenPort {
if host.ListenPort == h.ListenPort || host.ProxyListenPort == h.ProxyListenPort ||
host.ListenPort == h.ProxyListenPort || host.ProxyListenPort == h.ListenPort {
updateListenPorts(h)
count++
//protect against endless recursion
if count > 64535 {
if count > (math.MaxInt16 - 1000) {
reset = true
break
}
@@ -356,7 +358,7 @@ func HostExists(h *models.Host) bool {
func updateListenPorts(h *models.Host) {
h.ListenPort++
h.ProxyListenPort++
if h.ListenPort > 65535 || h.ProxyListenPort > 65535 {
if h.ListenPort > math.MaxInt16 || h.ProxyListenPort > math.MaxInt16 {
h.ListenPort = 1000
h.ProxyListenPort = 1001
}