mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 16:57:51 +08:00
set macaddress and nodeid if not set
This commit is contained in:

committed by
0xdcarns

parent
5c35ca433e
commit
e1bba1d89f
@@ -103,7 +103,8 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
|||||||
if cfg.Node.MacAddress == "" {
|
if cfg.Node.MacAddress == "" {
|
||||||
macs, err := ncutils.GetMacAddr()
|
macs, err := ncutils.GetMacAddr()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
//if macaddress can't be found set to random string
|
||||||
|
cfg.Node.MacAddress = ncutils.MakeRandomString(18)
|
||||||
} else {
|
} else {
|
||||||
cfg.Node.MacAddress = macs[0]
|
cfg.Node.MacAddress = macs[0]
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gravitl/netmaker/config"
|
"github.com/gravitl/netmaker/config"
|
||||||
|
"github.com/gravitl/netmaker/netclient/ncutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "dev"
|
var Version = "dev"
|
||||||
@@ -545,7 +546,11 @@ func GetNodeID() string {
|
|||||||
if os.Getenv("NODE_ID") != "" {
|
if os.Getenv("NODE_ID") != "" {
|
||||||
id = os.Getenv("NODE_ID")
|
id = os.Getenv("NODE_ID")
|
||||||
} else if config.Config.Server.NodeID != "" {
|
} else if config.Config.Server.NodeID != "" {
|
||||||
id = config.Config.Server.NodeID
|
id, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
id = ncutils.MakeRandomString(10)
|
||||||
|
}
|
||||||
|
config.Config.Server.NodeID = id
|
||||||
}
|
}
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user