mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
remove publish prior to registration with server
This commit is contained in:
@@ -42,10 +42,9 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error {
|
||||
if cfg.Node.Password == "" {
|
||||
cfg.Node.Password = logic.GenKey()
|
||||
}
|
||||
manualPort := false
|
||||
//check if ListenPort was set on command line
|
||||
if cfg.Node.ListenPort != 0 {
|
||||
cfg.Node.UDPHolePunch = "no"
|
||||
manualPort = true
|
||||
}
|
||||
var trafficPubKey, trafficPrivKey, errT = box.GenerateKey(rand.Reader) // generate traffic keys
|
||||
if errT != nil {
|
||||
@@ -172,10 +171,6 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error {
|
||||
}
|
||||
logger.Log(1, "node created on remote server...updating configs")
|
||||
cfg.Node = node
|
||||
logger.Log(1, "turn on UDP hole punching (dynamic port setting)? "+cfg.Node.UDPHolePunch)
|
||||
if !manualPort && (cfg.Node.UDPHolePunch == "no") {
|
||||
setListenPort(cfg)
|
||||
}
|
||||
err = config.ModNodeConfig(&cfg.Node)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -199,8 +194,10 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error {
|
||||
if cfg.Server.Server == "" {
|
||||
return errors.New("did not recieve broker address from registration")
|
||||
}
|
||||
|
||||
_ = UpdateLocalListenPort(cfg)
|
||||
// update server with latest data
|
||||
if err := PublishNodeUpdate(cfg); err != nil {
|
||||
logger.Log(0, "failed to publish update for join", err.Error())
|
||||
}
|
||||
|
||||
if cfg.Daemon == "install" || ncutils.IsFreeBSD() {
|
||||
err = daemon.InstallDaemon(cfg)
|
||||
@@ -229,20 +226,3 @@ func formatName(node models.Node) string {
|
||||
}
|
||||
return node.Name
|
||||
}
|
||||
|
||||
func setListenPort(cfg *config.ClientConfig) {
|
||||
// keep track of the returned listenport value
|
||||
newListenPort := cfg.Node.ListenPort
|
||||
var errN error
|
||||
// get free port based on returned default listen port
|
||||
cfg.Node.ListenPort, errN = ncutils.GetFreePort(cfg.Node.ListenPort)
|
||||
if errN != nil {
|
||||
cfg.Node.ListenPort = newListenPort
|
||||
logger.Log(1, "Error retrieving port: ", errN.Error())
|
||||
}
|
||||
|
||||
// if newListenPort has been modified to find an available port, publish to server
|
||||
if cfg.Node.ListenPort != newListenPort {
|
||||
PublishNodeUpdate(cfg)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user