From d75708512fd95264c76cdf23304715da63a42049 Mon Sep 17 00:00:00 2001 From: "Matthew R. Kasun" Date: Fri, 8 Jul 2022 15:16:32 -0400 Subject: [PATCH 1/3] fix version number in freebsd builds --- .github/workflows/buildandrelease.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/buildandrelease.yml b/.github/workflows/buildandrelease.yml index 6fb10674..230c1775 100644 --- a/.github/workflows/buildandrelease.yml +++ b/.github/workflows/buildandrelease.yml @@ -325,11 +325,11 @@ jobs: - name: Build run: | cd netclient - env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-X 'main.Version=${NETMAKER_VERSION}'" -o build/netclient-freebsd/netclient main.go - env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm5/netclient main.go - env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm6/netclient main.go - env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm7/netclient main.go - env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm64/netclient main.go + env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd/netclient . + env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=5 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm5/netclient . + env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=6 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm6/netclient . + env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=7 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm7/netclient . + env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-freebsd-arm64/netclient . - name: Upload freebsd to Release uses: svenstaro/upload-release-action@v2 From e8e783866ac6993005fc394b2ac6bb1818658e9f Mon Sep 17 00:00:00 2001 From: "Matthew R. Kasun" Date: Fri, 8 Jul 2022 15:47:45 -0400 Subject: [PATCH 2/3] remove pr-approval workflow --- .github/workflows/pr-approval.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/workflows/pr-approval.yml diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml deleted file mode 100644 index 3274ea20..00000000 --- a/.github/workflows/pr-approval.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Manual PR Testing -on: [pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: trstringer/manual-approval@v1 - with: - secret: ${{ secrets.DEVOPS_API_TOKEN }} - approvers: theguy951357,afeiszli,mattkasun,0xdcarns - minimum-approvals: 1 \ No newline at end of file From 7bfbf06eb511db2cb398dcc34ff36dcdd405d80e Mon Sep 17 00:00:00 2001 From: "Matthew R. Kasun" Date: Mon, 11 Jul 2022 08:15:46 -0400 Subject: [PATCH 3/3] update logic for determing when to check for free port --- netclient/functions/localport.go | 4 ++-- netclient/functions/localport_freebsd.go | 2 +- netclient/functions/mqhandlers.go | 15 ++++++++++----- netclient/functions/pull.go | 5 ++++- netclient/wireguard/common.go | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/netclient/functions/localport.go b/netclient/functions/localport.go index 97a65f4f..976515a1 100644 --- a/netclient/functions/localport.go +++ b/netclient/functions/localport.go @@ -23,7 +23,7 @@ func GetLocalListenPort(ifacename string) (int32, error) { defer client.Close() device, err := client.Device(ifacename) if err != nil { - logger.Log(0, "failed to parse interface") + logger.Log(0, "failed to parse interface", ifacename) return 0, err } return int32(device.ListenPort), nil @@ -35,7 +35,7 @@ func UpdateLocalListenPort(nodeCfg *config.ClientConfig) error { ifacename := getRealIface(nodeCfg.Node.Interface, nodeCfg.Node.Address) localPort, err := GetLocalListenPort(ifacename) if err != nil { - logger.Log(1, "error encountered checking local listen port: ", err.Error()) + logger.Log(1, "error encountered checking local listen port: ", ifacename, err.Error()) } else if nodeCfg.Node.LocalListenPort != localPort && localPort != 0 { logger.Log(1, "local port has changed from ", strconv.Itoa(int(nodeCfg.Node.LocalListenPort)), " to ", strconv.Itoa(int(localPort))) nodeCfg.Node.LocalListenPort = localPort diff --git a/netclient/functions/localport_freebsd.go b/netclient/functions/localport_freebsd.go index ab02fc9e..a24491a8 100644 --- a/netclient/functions/localport_freebsd.go +++ b/netclient/functions/localport_freebsd.go @@ -34,7 +34,7 @@ func UpdateLocalListenPort(nodeCfg *config.ClientConfig) error { var err error localPort, err := GetLocalListenPort(nodeCfg.Node.Interface) if err != nil { - logger.Log(1, "error encountered checking local listen port: ", err.Error()) + logger.Log(1, "error encountered checking local listen port for interface : ",nodeCfg.Node.Interface err.Error()) } else if nodeCfg.Node.LocalListenPort != localPort && localPort != 0 { logger.Log(1, "local port has changed from ", strconv.Itoa(int(nodeCfg.Node.LocalListenPort)), " to ", strconv.Itoa(int(localPort))) nodeCfg.Node.LocalListenPort = localPort diff --git a/netclient/functions/mqhandlers.go b/netclient/functions/mqhandlers.go index 2912fa58..34ed633e 100644 --- a/netclient/functions/mqhandlers.go +++ b/netclient/functions/mqhandlers.go @@ -106,12 +106,17 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) { file := ncutils.GetNetclientPathSpecific() + nodeCfg.Node.Interface + ".conf" if ifaceDelta { // if a change caused an ifacedelta we need to notify the server to update the peers - err = ncutils.ModPort(&newNode) - if err != nil { - logger.Log(0, "error modifying node port on", newNode.Name, "-", err.Error()) - return + if newNode.ListenPort != nodeCfg.Node.LocalListenPort { + if err := wireguard.RemoveConf(newNode.Interface, false); err != nil { + logger.Log(0, "error remove interface", newNode.Interface, err.Error()) + } + err = ncutils.ModPort(&newNode) + if err != nil { + logger.Log(0, "error modifying node port on", newNode.Name, "-", err.Error()) + return + } + informPortChange(&newNode) } - informPortChange(&newNode) if err := wireguard.UpdateWgInterface(file, privateKey, nameserver, newNode); err != nil { logger.Log(0, "error updating wireguard config "+err.Error()) return diff --git a/netclient/functions/pull.go b/netclient/functions/pull.go index b9457b23..87886a3f 100644 --- a/netclient/functions/pull.go +++ b/netclient/functions/pull.go @@ -62,7 +62,10 @@ func Pull(network string, iface bool) (*models.Node, error) { logger.Log(0, "unable to update server config: "+err.Error()) } } - if nodeGET.Node.ListenPort != cfg.Node.ListenPort { + if nodeGET.Node.ListenPort != cfg.Node.LocalListenPort { + if err := wireguard.RemoveConf(resNode.Interface, false); err != nil { + logger.Log(0, "error remove interface", resNode.Interface, err.Error()) + } err = ncutils.ModPort(&resNode) if err != nil { return nil, err diff --git a/netclient/wireguard/common.go b/netclient/wireguard/common.go index 67f2cfc7..79473fd9 100644 --- a/netclient/wireguard/common.go +++ b/netclient/wireguard/common.go @@ -548,7 +548,7 @@ func GetDevicePeers(iface string) ([]wgtypes.Peer, error) { defer client.Close() device, err := client.Device(iface) if err != nil { - logger.Log(0, "failed to parse interface") + logger.Log(0, "failed to parse interface", iface) return nil, err } return device.Peers, nil