mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-17 14:38:41 +08:00
fix logging vebosity by deleting more comms functions
This commit is contained in:
parent
5c48b5e474
commit
799f7f040c
1 changed files with 0 additions and 36 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue