|
@@ -4,9 +4,9 @@ import (
|
|
"errors"
|
|
"errors"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
|
|
+ "net"
|
|
"os"
|
|
"os"
|
|
"strconv"
|
|
"strconv"
|
|
-
|
|
|
|
"github.com/gravitl/netmaker/config"
|
|
"github.com/gravitl/netmaker/config"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -31,6 +31,7 @@ func GetServerConfig() config.ServerConfig {
|
|
cfg.AllowedOrigin = GetAllowedOrigin()
|
|
cfg.AllowedOrigin = GetAllowedOrigin()
|
|
cfg.RestBackend = "off"
|
|
cfg.RestBackend = "off"
|
|
cfg.Verbosity = GetVerbose()
|
|
cfg.Verbosity = GetVerbose()
|
|
|
|
+ cfg.NodeID = GetNodeID()
|
|
cfg.CheckinInterval = GetCheckinInterval()
|
|
cfg.CheckinInterval = GetCheckinInterval()
|
|
if IsRestBackend() {
|
|
if IsRestBackend() {
|
|
cfg.RestBackend = "on"
|
|
cfg.RestBackend = "on"
|
|
@@ -372,3 +373,30 @@ func IsSplitDNS() bool {
|
|
}
|
|
}
|
|
return issplit
|
|
return issplit
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func GetNodeID() string {
|
|
|
|
+ var id string
|
|
|
|
+ id = getMacAddr()
|
|
|
|
+ if os.Getenv("NODE_ID") != "" {
|
|
|
|
+ id = os.Getenv("NODE_ID")
|
|
|
|
+ } else if config.Config.Server.NodeID != "" {
|
|
|
|
+ id = config.Config.Server.NodeID
|
|
|
|
+ }
|
|
|
|
+ return id
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 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]
|
|
|
|
+}
|