mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-11 01:54:34 +08:00
circular imports resolved
This commit is contained in:
parent
16cf0eaeed
commit
8aeb6bbfd9
2 changed files with 10 additions and 24 deletions
6
main.go
6
main.go
|
@ -46,7 +46,11 @@ func initialize() { // Client Mode Prereq Check
|
|||
}
|
||||
|
||||
if servercfg.GetNodeID() == "" {
|
||||
logger.FatalLog("error: must set NODE_ID, currently blank")
|
||||
id, err := os.Hostname()
|
||||
if err != nil {
|
||||
id = ncutils.MakeRandomString(10)
|
||||
}
|
||||
servercfg.SetNodeID(id)
|
||||
}
|
||||
|
||||
if err = database.InitializeDatabase(); err != nil {
|
||||
|
|
|
@ -3,14 +3,12 @@ package servercfg
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gravitl/netmaker/config"
|
||||
"github.com/gravitl/netmaker/netclient/ncutils"
|
||||
)
|
||||
|
||||
var Version = "dev"
|
||||
|
@ -546,15 +544,15 @@ func GetNodeID() string {
|
|||
if os.Getenv("NODE_ID") != "" {
|
||||
id = os.Getenv("NODE_ID")
|
||||
} else if config.Config.Server.NodeID != "" {
|
||||
id, err := os.Hostname()
|
||||
if err != nil {
|
||||
id = ncutils.MakeRandomString(10)
|
||||
}
|
||||
config.Config.Server.NodeID = id
|
||||
id = config.Config.Server.NodeID
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func SetNodeID(id string) {
|
||||
config.Config.Server.NodeID = id
|
||||
}
|
||||
|
||||
// GetServerCheckinInterval - gets the server check-in time
|
||||
func GetServerCheckinInterval() int64 {
|
||||
var t = int64(5)
|
||||
|
@ -597,22 +595,6 @@ func GetAzureTenant() string {
|
|||
return azureTenant
|
||||
}
|
||||
|
||||
// GetMacAddr - get's mac address
|
||||
func getMacAddr() string {
|
||||
ifas, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
var as []string
|
||||
for _, ifa := range ifas {
|
||||
a := ifa.HardwareAddr.String()
|
||||
if a != "" {
|
||||
as = append(as, a)
|
||||
}
|
||||
}
|
||||
return as[0]
|
||||
}
|
||||
|
||||
// GetRce - sees if Rce is enabled, off by default
|
||||
func GetRce() bool {
|
||||
return os.Getenv("RCE") == "on" || config.Config.Server.RCE == "on"
|
||||
|
|
Loading…
Reference in a new issue