added inform port change util func

This commit is contained in:
0xdcarns 2022-07-07 09:52:20 -04:00
parent c481f27200
commit 5fc73e6a80
4 changed files with 13 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import (
"net"
"net/http"
"os"
"strconv"
"strings"
"github.com/gravitl/netmaker/logger"
@ -409,3 +410,11 @@ func SetServerInfo(cfg *config.ClientConfig) error {
return nil
}
func informPortChange(node *models.Node) {
if node.ListenPort == 0 {
logger.Log(0, "UDP hole punching enabled")
} else {
logger.Log(0, "using port", strconv.Itoa(int(node.ListenPort)))
}
}

View file

@ -9,7 +9,6 @@ import (
"log"
"net/http"
"runtime"
"strconv"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
@ -172,10 +171,11 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error {
}
logger.Log(1, "node created on remote server...updating configs")
err = ncutils.ModPort(&node)
logger.Log(0, "using port", strconv.Itoa(int(node.ListenPort)))
if err != nil {
return err
}
informPortChange(&node)
err = config.ModNodeConfig(&node)
if err != nil {
return err

View file

@ -111,6 +111,7 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
logger.Log(0, "error modifying node port on", newNode.Name, "-", err.Error())
return
}
informPortChange(&newNode)
if err := wireguard.UpdateWgInterface(file, privateKey, nameserver, newNode); err != nil {
logger.Log(0, "error updating wireguard config "+err.Error())
return

View file

@ -8,7 +8,6 @@ import (
"net/http"
"os"
"runtime"
"strconv"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/models"
@ -68,7 +67,7 @@ func Pull(network string, iface bool) (*models.Node, error) {
if err != nil {
return nil, err
}
logger.Log(0, "port is now", strconv.Itoa(int(resNode.ListenPort)))
informPortChange(&resNode)
}
if err = config.ModNodeConfig(&resNode); err != nil {
return nil, err