mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-17 14:38:41 +08:00
don't set node_id if invalid hostname
This commit is contained in:
parent
8aeb6bbfd9
commit
02f09799b8
2 changed files with 7 additions and 5 deletions
6
main.go
6
main.go
|
|
@ -46,11 +46,7 @@ func initialize() { // Client Mode Prereq Check
|
|||
}
|
||||
|
||||
if servercfg.GetNodeID() == "" {
|
||||
id, err := os.Hostname()
|
||||
if err != nil {
|
||||
id = ncutils.MakeRandomString(10)
|
||||
}
|
||||
servercfg.SetNodeID(id)
|
||||
logger.FatalLog("error: must set NODE_ID, currently blank")
|
||||
}
|
||||
|
||||
if err = database.InitializeDatabase(); err != nil {
|
||||
|
|
|
|||
|
|
@ -540,11 +540,17 @@ func IsHostNetwork() bool {
|
|||
// GetNodeID - gets the node id
|
||||
func GetNodeID() string {
|
||||
var id string
|
||||
var err error
|
||||
// id = getMacAddr()
|
||||
if os.Getenv("NODE_ID") != "" {
|
||||
id = os.Getenv("NODE_ID")
|
||||
} else if config.Config.Server.NodeID != "" {
|
||||
id = config.Config.Server.NodeID
|
||||
} else {
|
||||
id, err = os.Hostname()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue