fix logging vebosity by deleting more comms functions

This commit is contained in:
Matthew R. Kasun 2022-04-21 16:35:19 -04:00
parent 5c48b5e474
commit 799f7f040c

View file

@ -2,18 +2,13 @@ package servercfg
import (
"errors"
"fmt"
"io"
"math/rand"
"net"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/gravitl/netmaker/config"
"github.com/gravitl/netmaker/logger"
)
var (
@ -562,34 +557,3 @@ func GetRce() bool {
func GetDebug() bool {
return os.Getenv("DEBUG") == "on" || config.Config.Server.Debug == true
}
func genNewCommsCIDR() string {
currIfaces, err := net.Interfaces()
netrange := fmt.Sprintf("172.%d.0.0/16", genCommsByte())
if err == nil { // make sure chosen CIDR doesn't overlap with any local iface CIDRs
iter := 0
for i := 0; i < len(currIfaces); i++ {
if currentAddrs, err := currIfaces[i].Addrs(); err == nil {
for j := range currentAddrs {
if strings.Contains(currentAddrs[j].String(), netrange[0:7]) {
if iter > 20 { // if this hits, then the cidr should be specified
logger.FatalLog("could not find a suitable comms network on this server, please manually enter one")
}
netrange = fmt.Sprintf("172.%d.0.0/16", genCommsByte())
i = -1 // reset to loop back through
iter++ // track how many times you've iterated and not found one
break
}
}
}
}
}
return netrange
}
func genCommsByte() int {
const min = 1 << 4 // 16
const max = 1 << 5 // 32
rand.Seed(time.Now().UnixNano())
return rand.Intn(max-min) + min
}