浏览代码

Merge branch 'feature-messageQueue' into feature-messageQueue

Matthew R Kasun 3 年之前
父节点
当前提交
55109d869f
共有 47 个文件被更改,包括 202 次插入123 次删除
  1. 69 3
      .github/workflows/buildandrelease.yml
  2. 4 0
      .github/workflows/test-artifacts.yml
  3. 4 0
      .github/workflows/test.yml
  4. 2 1
      .gitignore
  5. 2 2
      README.md
  6. 2 2
      auth/azure-ad.go
  7. 2 2
      auth/github.go
  8. 2 2
      auth/google.go
  9. 2 2
      compose/docker-compose.caddy.yml
  10. 2 2
      compose/docker-compose.contained.yml
  11. 2 2
      compose/docker-compose.nodns.yml
  12. 2 2
      compose/docker-compose.reference.yml
  13. 2 2
      compose/docker-compose.yml
  14. 1 0
      config/config.go
  15. 3 4
      controllers/controller.go
  16. 2 3
      controllers/dns_test.go
  17. 7 2
      controllers/network.go
  18. 6 0
      controllers/node.go
  19. 7 0
      controllers/node_grpc.go
  20. 1 1
      docs/api.rst
  21. 3 3
      docs/architecture.rst
  22. 3 3
      go.mod
  23. 6 6
      go.sum
  24. 1 2
      logger/logger.go
  25. 1 2
      logic/dns.go
  26. 4 0
      logic/nodes.go
  27. 3 6
      logic/wireguard.go
  28. 5 7
      main.go
  29. 6 6
      netclient/auth/auth.go
  30. 4 5
      netclient/config/config.go
  31. 1 2
      netclient/daemon/macos.go
  32. 2 3
      netclient/daemon/systemd.go
  33. 1 2
      netclient/daemon/windows.go
  34. 2 2
      netclient/functions/join.go
  35. 1 2
      netclient/local/dns.go
  36. 1 1
      netclient/main.go
  37. 2 3
      netclient/ncutils/netclientutils.go
  38. 1 1
      netclient/ncutils/netclientutils_darwin.go
  39. 1 1
      netclient/ncutils/netclientutils_freebsd.go
  40. 1 3
      netclient/ncutils/netclientutils_linux.go
  41. 1 1
      netclient/ncutils/netclientutils_windows.go
  42. 2 3
      netclient/ncwindows/windows.go
  43. 1 1
      netclient/netclient.exe.manifest.xml
  44. 1 1
      netclient/versioninfo.json
  45. 8 18
      netclient/wireguard/common.go
  46. 3 4
      netclient/wireguard/unix.go
  47. 13 3
      servercfg/serverconf.go

+ 69 - 3
.github/workflows/buildandrelease.yml

@@ -7,7 +7,7 @@ on:
         description: 'Netmaker version'
         description: 'Netmaker version'
         required: false
         required: false
   release:
   release:
-    types: [created]
+    types: [published]
 
 
 jobs:
 jobs:
   build:
   build:
@@ -29,7 +29,7 @@ jobs:
       - name: Setup go
       - name: Setup go
         uses: actions/setup-go@v2
         uses: actions/setup-go@v2
         with:
         with:
-          go-version: 1.16
+          go-version: 1.17
 
 
       - name: Build
       - name: Build
         run: |
         run: |
@@ -40,7 +40,13 @@ jobs:
           env GOOS=linux GOARCH=arm GOARM=7 go build -o build/netclient-arm7/netclient main.go
           env GOOS=linux GOARCH=arm GOARM=7 go build -o build/netclient-arm7/netclient main.go
           env GOOS=linux GOARCH=arm64 go build -o build/netclient-arm64/netclient main.go
           env GOOS=linux GOARCH=arm64 go build -o build/netclient-arm64/netclient main.go
           env GOOS=linux GOARCH=mipsle go build -ldflags "-s -w" -o build/netclient-mipsle/netclient main.go && upx build/netclient-mipsle/netclient
           env GOOS=linux GOARCH=mipsle go build -ldflags "-s -w" -o build/netclient-mipsle/netclient main.go && upx build/netclient-mipsle/netclient
-
+          env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o build/netclient-freebsd/netclient main.go
+          env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=5 go build -o build/netclient-freebsd-arm5/netclient main.go
+          env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=6 go build -o build/netclient-freebsd-arm6/netclient main.go
+          env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm GOARM=7 go build -o build/netclient-freebsd-arm7/netclient main.go
+          env CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -o build/netclient-freebsd-arm64/netclient main.go
+          env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o build/netclient-darwin/netclient main.go
+          
       - name: Upload x86 to Release
       - name: Upload x86 to Release
         uses: svenstaro/upload-release-action@v2
         uses: svenstaro/upload-release-action@v2
         with:
         with:
@@ -100,3 +106,63 @@ jobs:
           overwrite: true
           overwrite: true
           prerelease: true
           prerelease: true
           asset_name: netclient-mipsle
           asset_name: netclient-mipsle
+
+      - name: Upload freebsd to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-freebsd/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-freebsd      
+          
+      - name: Upload freebsd-arm5 to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-freebsd-arm5/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-freebsd-arm5
+          
+      - name: Upload freebsd-arm6 to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-freebsd-arm6/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-freebsd-arm6
+          
+      - name: Upload freebsd-arm7 to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-freebsd-arm7/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-freebsd-arm7
+          
+      - name: Upload freebsd-arm64 to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-freebsd-arm64/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-freebsd-arm64
+          
+      - name: Upload darwin to Release
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: netclient/build/netclient-darwin/netclient
+          tag: ${{ env.NETMAKER_VERSION }}
+          overwrite: true
+          prerelease: true
+          asset_name: netclient-darwin

+ 4 - 0
.github/workflows/test-artifacts.yml

@@ -12,6 +12,10 @@ jobs:
         steps:
         steps:
             - name: Checkout
             - name: Checkout
               uses: actions/checkout@v2
               uses: actions/checkout@v2
+            - name: Setup Go
+              uses: actions/setup-go@v2
+              with:
+                  go-version: 1.17
             - name: Set up QEMU
             - name: Set up QEMU
               uses: docker/setup-qemu-action@v1
               uses: docker/setup-qemu-action@v1
             - name: Set up Docker Buildx
             - name: Set up Docker Buildx

+ 4 - 0
.github/workflows/test.yml

@@ -11,6 +11,10 @@ jobs:
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@v2
         uses: actions/checkout@v2
+      - name: Setup Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: 1.17
       - name: run tests
       - name: run tests
         run: |
         run: |
             go test -p 1 ./... -v
             go test -p 1 ./... -v

+ 2 - 1
.gitignore

@@ -15,4 +15,5 @@ netclient/netclient32
 netclient/netclient.exe
 netclient/netclient.exe
 config/dnsconfig/
 config/dnsconfig/
 data/
 data/
-.vscode/
+.idea/
+

+ 2 - 2
README.md

@@ -8,7 +8,7 @@
 
 
 <p align="center">
 <p align="center">
   <a href="https://github.com/gravitl/netmaker/releases">
   <a href="https://github.com/gravitl/netmaker/releases">
-    <img src="https://img.shields.io/badge/Version-0.9.2-informational?style=flat-square" />
+    <img src="https://img.shields.io/badge/Version-0.9.3-informational?style=flat-square" />
   </a>
   </a>
   <a href="https://hub.docker.com/r/gravitl/netmaker/tags">
   <a href="https://hub.docker.com/r/gravitl/netmaker/tags">
     <img src="https://img.shields.io/docker/pulls/gravitl/netmaker" />
     <img src="https://img.shields.io/docker/pulls/gravitl/netmaker" />
@@ -47,7 +47,7 @@
 
 
 <img src="./docs/images/install-server.gif" width="50%" /><img src="./docs/images/visit-website.gif" width="50%" />
 <img src="./docs/images/install-server.gif" width="50%" /><img src="./docs/images/visit-website.gif" width="50%" />
 
 
-Upon completion, the logs will display the instructions to connect various devices. These can also be retrived from the UI under "Access Keys."
+Upon completion, the logs will display the instructions to connect various devices. These can also be retrieved from the UI under "Access Keys."
 
 
 After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://netmaker.readthedocs.io/en/master/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://gravitl.com/resources) for different use cases, including Kubernetes.
 After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://netmaker.readthedocs.io/en/master/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://gravitl.com/resources) for different use cases, including Kubernetes.
 
 

+ 2 - 2
auth/azure-ad.go

@@ -3,7 +3,7 @@ package auth
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/http"
 
 
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logger"
@@ -109,7 +109,7 @@ func getAzureUserInfo(state string, code string) (*azureOauthUser, error) {
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 	}
 	}
 	defer response.Body.Close()
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	if err != nil {
 	if err != nil {
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 	}
 	}

+ 2 - 2
auth/github.go

@@ -3,7 +3,7 @@ package auth
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/http"
 
 
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logger"
@@ -113,7 +113,7 @@ func getGithubUserInfo(state string, code string) (*githubOauthUser, error) {
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 	}
 	}
 	defer response.Body.Close()
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	if err != nil {
 	if err != nil {
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 	}
 	}

+ 2 - 2
auth/google.go

@@ -3,7 +3,7 @@ package auth
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/http"
 
 
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logger"
@@ -104,7 +104,7 @@ func getGoogleUserInfo(state string, code string) (*googleOauthUser, error) {
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 		return nil, fmt.Errorf("failed getting user info: %s", err.Error())
 	}
 	}
 	defer response.Body.Close()
 	defer response.Body.Close()
-	contents, err := ioutil.ReadAll(response.Body)
+	contents, err := io.ReadAll(response.Body)
 	if err != nil {
 	if err != nil {
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 		return nil, fmt.Errorf("failed reading response body: %s", err.Error())
 	}
 	}

+ 2 - 2
compose/docker-compose.caddy.yml

@@ -3,7 +3,7 @@ version: "3.4"
 services:
 services:
   netmaker:
   netmaker:
     container_name: netmaker
     container_name: netmaker
-    image: gravitl/netmaker:v0.9.2
+    image: gravitl/netmaker:v0.9.3
     volumes:
     volumes:
       - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
       - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
       - /run/systemd/system:/run/systemd/system
       - /run/systemd/system:/run/systemd/system
@@ -40,7 +40,7 @@ services:
     container_name: netmaker-ui
     container_name: netmaker-ui
     depends_on:
     depends_on:
       - netmaker
       - netmaker
-    image: gravitl/netmaker-ui:v0.9.2
+    image: gravitl/netmaker-ui:v0.9.3
     links:
     links:
       - "netmaker:api"
       - "netmaker:api"
     ports:
     ports:

+ 2 - 2
compose/docker-compose.contained.yml

@@ -3,7 +3,7 @@ version: "3.4"
 services:
 services:
   netmaker:
   netmaker:
     container_name: netmaker
     container_name: netmaker
-    image: gravitl/netmaker:v0.9.2
+    image: gravitl/netmaker:v0.9.3
     volumes:
     volumes:
       - dnsconfig:/root/config/dnsconfig
       - dnsconfig:/root/config/dnsconfig
       - /usr/bin/wg:/usr/bin/wg
       - /usr/bin/wg:/usr/bin/wg
@@ -38,7 +38,7 @@ services:
     container_name: netmaker-ui
     container_name: netmaker-ui
     depends_on:
     depends_on:
       - netmaker
       - netmaker
-    image: gravitl/netmaker-ui:v0.9.2
+    image: gravitl/netmaker-ui:v0.9.3
     links:
     links:
       - "netmaker:api"
       - "netmaker:api"
     ports:
     ports:

+ 2 - 2
compose/docker-compose.nodns.yml

@@ -3,7 +3,7 @@ version: "3.4"
 services:
 services:
   netmaker:
   netmaker:
     container_name: netmaker
     container_name: netmaker
-    image: gravitl/netmaker:v0.9.2
+    image: gravitl/netmaker:v0.9.3
     volumes:
     volumes:
       - /usr/bin/wg:/usr/bin/wg
       - /usr/bin/wg:/usr/bin/wg
       - sqldata:/root/data
       - sqldata:/root/data
@@ -36,7 +36,7 @@ services:
     container_name: netmaker-ui
     container_name: netmaker-ui
     depends_on:
     depends_on:
       - netmaker
       - netmaker
-    image: gravitl/netmaker-ui:v0.9.2
+    image: gravitl/netmaker-ui:v0.9.3
     links:
     links:
       - "netmaker:api"
       - "netmaker:api"
     ports:
     ports:

+ 2 - 2
compose/docker-compose.reference.yml

@@ -11,7 +11,7 @@ services:
     container_name: netmaker
     container_name: netmaker
     depends_on:
     depends_on:
       - rqlite
       - rqlite
-    image: gravitl/netmaker:v0.9.2
+    image: gravitl/netmaker:v0.9.3
     volumes: # Volume mounts necessary for CLIENT_MODE to control wireguard networking on host (except dnsconfig, which is where dns config files are stored for use by CoreDNS)
     volumes: # Volume mounts necessary for CLIENT_MODE to control wireguard networking on host (except dnsconfig, which is where dns config files are stored for use by CoreDNS)
       - dnsconfig:/root/config/dnsconfig # Netmaker writes Corefile to this location, which gets mounted by CoreDNS for DNS configuration.
       - dnsconfig:/root/config/dnsconfig # Netmaker writes Corefile to this location, which gets mounted by CoreDNS for DNS configuration.
       - /usr/bin/wg:/usr/bin/wg
       - /usr/bin/wg:/usr/bin/wg
@@ -41,7 +41,7 @@ services:
     container_name: netmaker-ui
     container_name: netmaker-ui
     depends_on:
     depends_on:
       - netmaker
       - netmaker
-    image: gravitl/netmaker-ui:v0.9.2
+    image: gravitl/netmaker-ui:v0.9.3
     links:
     links:
       - "netmaker:api"
       - "netmaker:api"
     ports:
     ports:

+ 2 - 2
compose/docker-compose.yml

@@ -3,7 +3,7 @@ version: "3.4"
 services:
 services:
   netmaker:
   netmaker:
     container_name: netmaker
     container_name: netmaker
-    image: gravitl/netmaker:v0.9.0
+    image: gravitl/netmaker:v0.9.3
     volumes:
     volumes:
       - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
       - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
       - /run/systemd/system:/run/systemd/system
       - /run/systemd/system:/run/systemd/system
@@ -40,7 +40,7 @@ services:
     container_name: netmaker-ui
     container_name: netmaker-ui
     depends_on:
     depends_on:
       - netmaker
       - netmaker
-    image: gravitl/netmaker-ui:v0.9.2
+    image: gravitl/netmaker-ui:v0.9.3
     links:
     links:
       - "netmaker:api"
       - "netmaker:api"
     ports:
     ports:

+ 1 - 0
config/config.go

@@ -69,6 +69,7 @@ type ServerConfig struct {
 	FrontendURL           string `yaml:"frontendurl"`
 	FrontendURL           string `yaml:"frontendurl"`
 	DisplayKeys           string `yaml:"displaykeys"`
 	DisplayKeys           string `yaml:"displaykeys"`
 	AzureTenant           string `yaml:"azuretenant"`
 	AzureTenant           string `yaml:"azuretenant"`
+	RCE                   string `yaml:"rce"`
 }
 }
 
 
 // SQLConfig - Generic SQL Config
 // SQLConfig - Generic SQL Config

+ 3 - 4
controllers/controller.go

@@ -52,20 +52,19 @@ func HandleRESTRequests(wg *sync.WaitGroup) {
 		}
 		}
 	}()
 	}()
 	logger.Log(0, "REST Server successfully started on port ", port, " (REST)")
 	logger.Log(0, "REST Server successfully started on port ", port, " (REST)")
-	c := make(chan os.Signal)
 
 
 	// Relay os.Interrupt to our channel (os.Interrupt = CTRL+C)
 	// Relay os.Interrupt to our channel (os.Interrupt = CTRL+C)
 	// Ignore other incoming signals
 	// Ignore other incoming signals
-	signal.Notify(c, os.Interrupt)
+	ctx, stop := signal.NotifyContext(context.TODO(), os.Interrupt)
+	defer stop()
 
 
 	// Block main routine until a signal is received
 	// Block main routine until a signal is received
 	// As long as user doesn't press CTRL+C a message is not passed and our main routine keeps running
 	// As long as user doesn't press CTRL+C a message is not passed and our main routine keeps running
-	<-c
+	<-ctx.Done()
 
 
 	// After receiving CTRL+C Properly stop the server
 	// After receiving CTRL+C Properly stop the server
 	logger.Log(0, "Stopping the REST server...")
 	logger.Log(0, "Stopping the REST server...")
 	srv.Shutdown(context.TODO())
 	srv.Shutdown(context.TODO())
 	logger.Log(0, "REST Server closed.")
 	logger.Log(0, "REST Server closed.")
 	logger.DumpFile(fmt.Sprintf("data/netmaker.log.%s", time.Now().Format(logger.TimeFormatDay)))
 	logger.DumpFile(fmt.Sprintf("data/netmaker.log.%s", time.Now().Format(logger.TimeFormatDay)))
-
 }
 }

+ 2 - 3
controllers/dns_test.go

@@ -1,7 +1,6 @@
 package controller
 package controller
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"testing"
 	"testing"
 
 
@@ -200,7 +199,7 @@ func TestSetDNS(t *testing.T) {
 		info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
 		info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
 		assert.False(t, info.IsDir())
 		assert.False(t, info.IsDir())
-		content, err := ioutil.ReadFile("./config/dnsconfig/netmaker.hosts")
+		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
 		assert.Contains(t, string(content), "testnode.skynet")
 		assert.Contains(t, string(content), "testnode.skynet")
 	})
 	})
@@ -212,7 +211,7 @@ func TestSetDNS(t *testing.T) {
 		info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
 		info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
 		assert.False(t, info.IsDir())
 		assert.False(t, info.IsDir())
-		content, err := ioutil.ReadFile("./config/dnsconfig/netmaker.hosts")
+		content, err := os.ReadFile("./config/dnsconfig/netmaker.hosts")
 		assert.Nil(t, err)
 		assert.Nil(t, err)
 		assert.Contains(t, string(content), "newhost.skynet")
 		assert.Contains(t, string(content), "newhost.skynet")
 	})
 	})

+ 7 - 2
controllers/network.go

@@ -68,7 +68,7 @@ func getNetworks(w http.ResponseWriter, r *http.Request) {
 	json.NewEncoder(w).Encode(allnetworks)
 	json.NewEncoder(w).Encode(allnetworks)
 }
 }
 
 
-//Simple get network function
+// Simple get network function
 func getNetwork(w http.ResponseWriter, r *http.Request) {
 func getNetwork(w http.ResponseWriter, r *http.Request) {
 	// set header.
 	// set header.
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")
@@ -101,7 +101,7 @@ func keyUpdate(w http.ResponseWriter, r *http.Request) {
 	json.NewEncoder(w).Encode(network)
 	json.NewEncoder(w).Encode(network)
 }
 }
 
 
-//Update a network
+// Update a network
 func updateNetwork(w http.ResponseWriter, r *http.Request) {
 func updateNetwork(w http.ResponseWriter, r *http.Request) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")
 	var params = mux.Vars(r)
 	var params = mux.Vars(r)
@@ -119,6 +119,11 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) {
 		return
 		return
 	}
 	}
 
 
+	if !servercfg.GetRce() {
+		newNetwork.DefaultPostDown = network.DefaultPostDown
+		newNetwork.DefaultPostUp = network.DefaultPostUp
+	}
+
 	rangeupdate, localrangeupdate, err := logic.UpdateNetwork(&network, &newNetwork)
 	rangeupdate, localrangeupdate, err := logic.UpdateNetwork(&network, &newNetwork)
 	if err != nil {
 	if err != nil {
 		returnErrorResponse(w, r, formatError(err, "badrequest"))
 		returnErrorResponse(w, r, formatError(err, "badrequest"))

+ 6 - 0
controllers/node.go

@@ -524,6 +524,12 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
 			}
 			}
 		}
 		}
 	}
 	}
+
+	if !servercfg.GetRce() {
+		newNode.PostDown = node.PostDown
+		newNode.PostUp = node.PostUp
+	}
+
 	err = logic.UpdateNode(&node, &newNode)
 	err = logic.UpdateNode(&node, &newNode)
 	if err != nil {
 	if err != nil {
 		returnErrorResponse(w, r, formatError(err, "internal"))
 		returnErrorResponse(w, r, formatError(err, "internal"))

+ 7 - 0
controllers/node_grpc.go

@@ -10,6 +10,7 @@ import (
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logic"
 	"github.com/gravitl/netmaker/logic"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
+	"github.com/gravitl/netmaker/servercfg"
 )
 )
 
 
 // NodeServiceServer - represents the service server for gRPC
 // NodeServiceServer - represents the service server for gRPC
@@ -107,6 +108,12 @@ func (s *NodeServiceServer) UpdateNode(ctx context.Context, req *nodepb.Object)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
+
+	if !servercfg.GetRce() {
+		newnode.PostDown = node.PostDown
+		newnode.PostUp = node.PostUp
+	}
+
 	err = logic.UpdateNode(&node, &newnode)
 	err = logic.UpdateNode(&node, &newnode)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 1 - 1
docs/api.rst

@@ -12,7 +12,7 @@ Authentication
 ==============
 ==============
 API calls must be authenticated via a header of  the format  `-H "Authorization: Bearer <YOUR_SECRET_KEY>"` There are two methods to obtain YOUR_SECRET_KEY:
 API calls must be authenticated via a header of  the format  `-H "Authorization: Bearer <YOUR_SECRET_KEY>"` There are two methods to obtain YOUR_SECRET_KEY:
 1. Using the masterkey. By default, this value is "secret key," but you should change this on your instance and keep it secure. This value can be set via env var at startup or in a config file (config/environments/< env >.yaml). See the [general usage](./USAGE.md) documentation for more details.
 1. Using the masterkey. By default, this value is "secret key," but you should change this on your instance and keep it secure. This value can be set via env var at startup or in a config file (config/environments/< env >.yaml). See the [general usage](./USAGE.md) documentation for more details.
-2. Using a JWT recieved for a node. This  can be retrieved by calling the `/api/nodes/<network>/authenticate` endpoint, as documented below.
+2. Using a JWT received for a node. This  can be retrieved by calling the `/api/nodes/<network>/authenticate` endpoint, as documented below.
 
 
 
 
 Format of Calls for Curl
 Format of Calls for Curl

+ 3 - 3
docs/architecture.rst

@@ -21,7 +21,7 @@ WireGuard
 
 
 WireGuard is a relatively new but very important technology which was recently added to the Linux kernel. WireGuard creates very fast but simple encrypted tunnels between devices. From the `WireGuard <https://www.wireguard.com/>`_ website, "it might be regarded as the most secure, easiest to use, and simplest VPN solution in the industry."
 WireGuard is a relatively new but very important technology which was recently added to the Linux kernel. WireGuard creates very fast but simple encrypted tunnels between devices. From the `WireGuard <https://www.wireguard.com/>`_ website, "it might be regarded as the most secure, easiest to use, and simplest VPN solution in the industry."
 
 
-Previous solutions like OpenVPN and IPSec are considerably more heavy and complex, while being less performant. All existing VPN tunnelling solutions will cause a significant increase in your network latency. WireGuard is the first to achieve near over-the-line network speeds, meaning you see no signigifant performance impact.  With the release of WireGuard, there is little reason to use any other existing tunnel encryption technology.
+Previous solutions like OpenVPN and IPSec are considerably more heavy and complex, while being less performant. All existing VPN tunneling solutions will cause a significant increase in your network latency. WireGuard is the first to achieve near over-the-line network speeds, meaning you see no significant performance impact.  With the release of WireGuard, there is little reason to use any other existing tunnel encryption technology.
 
 
 Mesh Network
 Mesh Network
 -------------
 -------------
@@ -56,7 +56,7 @@ Netmaker does a lot of work to set configurations for you, so that you don't hav
 Node
 Node
 ------
 ------
 
 
-A machine in a Netmaker network, which is managed by the Netclient, is referred to as a Node, as you will see in the UI. A Node can be a VM, a bare metal server, a desktop computer, an IoT device, or any other number of internet-connected machines on which the netclient is installed. A node is simply an endpoint in the network, which can send traffic to all the other nodes, and recieve traffic from all of the other nodes.
+A machine in a Netmaker network, which is managed by the Netclient, is referred to as a Node, as you will see in the UI. A Node can be a VM, a bare metal server, a desktop computer, an IoT device, or any other number of internet-connected machines on which the netclient is installed. A node is simply an endpoint in the network, which can send traffic to all the other nodes, and receive traffic from all of the other nodes.
 
 
 SystemD
 SystemD
 -------
 -------
@@ -153,7 +153,7 @@ Below is a high level, step-by-step overview of the flow of communications withi
 9. Netmaker server verifies information and creates the node, setting default values for any missing information. 
 9. Netmaker server verifies information and creates the node, setting default values for any missing information. 
 10. Timestamp is set for the network (see #16). 
 10. Timestamp is set for the network (see #16). 
 11. Netmaker returns settings as response to netclient. Some settings may be added or modified based on the network.
 11. Netmaker returns settings as response to netclient. Some settings may be added or modified based on the network.
-12. Netclient recieves response. If successful, it takes any additional info returned from Netmaker and configures the local system/WireGuard
+12. Netclient receives response. If successful, it takes any additional info returned from Netmaker and configures the local system/WireGuard
 13. Netclient sends another request to Netmaker's GRPC server, this time to retrieve the peers list (all other clients in the network).
 13. Netclient sends another request to Netmaker's GRPC server, this time to retrieve the peers list (all other clients in the network).
 14. Netmaker sends back peers list, including current known configurations of all nodes in network.
 14. Netmaker sends back peers list, including current known configurations of all nodes in network.
 15. Netclient configures WireGuard with this information. At this point, the node is fully configured as a part of the network and should be able to reach the other nodes via private address.
 15. Netclient configures WireGuard with this information. At this point, the node is fully configured as a part of the network and should be able to reach the other nodes via private address.

+ 3 - 3
go.mod

@@ -3,13 +3,13 @@ module github.com/gravitl/netmaker
 go 1.17
 go 1.17
 
 
 require (
 require (
-	github.com/go-playground/validator/v10 v10.9.0
+	github.com/go-playground/validator/v10 v10.10.0
 	github.com/golang-jwt/jwt/v4 v4.2.0
 	github.com/golang-jwt/jwt/v4 v4.2.0
 	github.com/golang/protobuf v1.5.2 // indirect
 	github.com/golang/protobuf v1.5.2 // indirect
 	github.com/gorilla/handlers v1.5.1
 	github.com/gorilla/handlers v1.5.1
 	github.com/gorilla/mux v1.8.0
 	github.com/gorilla/mux v1.8.0
 	github.com/lib/pq v1.10.4
 	github.com/lib/pq v1.10.4
-	github.com/mattn/go-sqlite3 v1.14.9
+	github.com/mattn/go-sqlite3 v1.14.10
 	github.com/rqlite/gorqlite v0.0.0-20210514125552-08ff1e76b22f
 	github.com/rqlite/gorqlite v0.0.0-20210514125552-08ff1e76b22f
 	github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
 	github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
 	github.com/stretchr/testify v1.7.0
 	github.com/stretchr/testify v1.7.0
@@ -23,7 +23,7 @@ require (
 	golang.zx2c4.com/wireguard v0.0.0-20210805125648-3957e9b9dd19 // indirect
 	golang.zx2c4.com/wireguard v0.0.0-20210805125648-3957e9b9dd19 // indirect
 	golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210913210325-91d1988e44de
 	golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210913210325-91d1988e44de
 	google.golang.org/genproto v0.0.0-20210201151548-94839c025ad4 // indirect
 	google.golang.org/genproto v0.0.0-20210201151548-94839c025ad4 // indirect
-	google.golang.org/grpc v1.42.0
+	google.golang.org/grpc v1.43.0
 	google.golang.org/protobuf v1.27.1
 	google.golang.org/protobuf v1.27.1
 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
 )
 )

+ 6 - 6
go.sum

@@ -44,8 +44,8 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb
 github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
 github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
 github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
 github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
 github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
 github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
-github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A=
-github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
+github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
+github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
 github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
 github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU=
 github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
 github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -108,8 +108,8 @@ github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ic
 github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
 github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
 github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
-github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
+github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43 h1:WgyLFv10Ov49JAQI/ZLUkCZ7VJS3r74hwFIGXJsgZlY=
 github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43 h1:WgyLFv10Ov49JAQI/ZLUkCZ7VJS3r74hwFIGXJsgZlY=
 github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43/go.mod h1:+t7E0lkKfbBsebllff1xdTmyJt8lH37niI6kwFk9OTo=
 github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43/go.mod h1:+t7E0lkKfbBsebllff1xdTmyJt8lH37niI6kwFk9OTo=
 github.com/mdlayher/genetlink v1.0.0 h1:OoHN1OdyEIkScEmRgxLEe2M9U8ClMytqA5niynLtfj0=
 github.com/mdlayher/genetlink v1.0.0 h1:OoHN1OdyEIkScEmRgxLEe2M9U8ClMytqA5niynLtfj0=
@@ -271,8 +271,8 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ
 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
 google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
 google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
-google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
-google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
+google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM=
+google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
 google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
 google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

+ 1 - 2
logger/logger.go

@@ -2,7 +2,6 @@ package logger
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"sort"
 	"sort"
 	"strconv"
 	"strconv"
@@ -90,7 +89,7 @@ func DumpFile(filePath string) {
 
 
 // Retrieve - retrieves logs from given file
 // Retrieve - retrieves logs from given file
 func Retrieve(filePath string) string {
 func Retrieve(filePath string) string {
-	contents, err := ioutil.ReadFile(filePath)
+	contents, err := os.ReadFile(filePath)
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}

+ 1 - 2
logic/dns.go

@@ -2,7 +2,6 @@ package logic
 
 
 import (
 import (
 	"encoding/json"
 	"encoding/json"
-	"io/ioutil"
 	"os"
 	"os"
 
 
 	"github.com/go-playground/validator/v10"
 	"github.com/go-playground/validator/v10"
@@ -135,7 +134,7 @@ func SetCorefile(domains string) error {
 `
 `
 	corebytes := []byte(corefile)
 	corebytes := []byte(corefile)
 
 
-	err = ioutil.WriteFile(dir+"/config/dnsconfig/Corefile", corebytes, 0644)
+	err = os.WriteFile(dir+"/config/dnsconfig/Corefile", corebytes, 0644)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 4 - 0
logic/nodes.go

@@ -253,6 +253,10 @@ func SetNodeDefaults(node *models.Node) {
 		postup := parentNetwork.DefaultPostUp
 		postup := parentNetwork.DefaultPostUp
 		node.PostUp = postup
 		node.PostUp = postup
 	}
 	}
+	if node.PostDown == "" {
+		postdown := parentNetwork.DefaultPostDown
+		node.PostDown = postdown
+	}
 	if node.IsStatic == "" {
 	if node.IsStatic == "" {
 		node.IsStatic = "no"
 		node.IsStatic = "no"
 	}
 	}

+ 3 - 6
logic/wireguard.go

@@ -3,7 +3,6 @@ package logic
 import (
 import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"os/exec"
 	"os/exec"
 	"strconv"
 	"strconv"
@@ -13,7 +12,6 @@ import (
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/netclient/ncutils"
 	"github.com/gravitl/netmaker/netclient/ncutils"
-	"github.com/gravitl/netmaker/servercfg"
 	"golang.zx2c4.com/wireguard/wgctrl"
 	"golang.zx2c4.com/wireguard/wgctrl"
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
 )
 )
@@ -87,11 +85,10 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 
 
 	if !ncutils.IsKernel() {
 	if !ncutils.IsKernel() {
 		var newConf string
 		var newConf string
-		var nameserver string
-		newConf, _ = ncutils.CreateWireGuardConf(node.Address, key.String(), strconv.FormatInt(int64(node.ListenPort), 10), node.MTU, nameserver, servercfg.GetCoreDNSAddr(), node.PersistentKeepalive, peers)
+		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), strconv.FormatInt(int64(node.ListenPort), 10), peers)
 		confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
 		confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
 		logger.Log(1, "writing wg conf file to:", confPath)
 		logger.Log(1, "writing wg conf file to:", confPath)
-		err = ioutil.WriteFile(confPath, []byte(newConf), 0644)
+		err = os.WriteFile(confPath, []byte(newConf), 0644)
 		if err != nil {
 		if err != nil {
 			logger.Log(1, "error writing wg conf file to", confPath, ":", err.Error())
 			logger.Log(1, "error writing wg conf file to", confPath, ":", err.Error())
 			return err
 			return err
@@ -99,7 +96,7 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 		if ncutils.IsWindows() {
 		if ncutils.IsWindows() {
 			wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
 			wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
 			logger.Log(1, "writing wg conf file to:", confPath)
 			logger.Log(1, "writing wg conf file to:", confPath)
-			err = ioutil.WriteFile(wgConfPath, []byte(newConf), 0644)
+			err = os.WriteFile(wgConfPath, []byte(newConf), 0644)
 			if err != nil {
 			if err != nil {
 				logger.Log(1, "error writing wg conf file to", wgConfPath, ":", err.Error())
 				logger.Log(1, "error writing wg conf file to", wgConfPath, ":", err.Error())
 				return err
 				return err

+ 5 - 7
main.go

@@ -1,6 +1,7 @@
 package main
 package main
 
 
 import (
 import (
+	"context"
 	"fmt"
 	"fmt"
 	"net"
 	"net"
 	"os"
 	"os"
@@ -157,21 +158,18 @@ func runGRPC(wg *sync.WaitGroup) {
 	}()
 	}()
 	logger.Log(0, "Agent Server successfully started on port ", grpcport, "(gRPC)")
 	logger.Log(0, "Agent Server successfully started on port ", grpcport, "(gRPC)")
 
 
-	// Right way to stop the server using a SHUTDOWN HOOK
-	// Create a channel to receive OS signals
-	c := make(chan os.Signal, 1)
-
 	// Relay os.Interrupt to our channel (os.Interrupt = CTRL+C)
 	// Relay os.Interrupt to our channel (os.Interrupt = CTRL+C)
 	// Ignore other incoming signals
 	// Ignore other incoming signals
-	signal.Notify(c, os.Interrupt)
+	ctx, stop := signal.NotifyContext(context.TODO(), os.Interrupt)
+	defer stop()
 
 
 	// Block main routine until a signal is received
 	// Block main routine until a signal is received
 	// As long as user doesn't press CTRL+C a message is not passed and our main routine keeps running
 	// As long as user doesn't press CTRL+C a message is not passed and our main routine keeps running
-	<-c
+	<-ctx.Done()
 
 
 	// After receiving CTRL+C Properly stop the server
 	// After receiving CTRL+C Properly stop the server
 	logger.Log(0, "Stopping the Agent server...")
 	logger.Log(0, "Stopping the Agent server...")
-	s.Stop()
+	s.GracefulStop()
 	listener.Close()
 	listener.Close()
 	logger.Log(0, "Agent server closed..")
 	logger.Log(0, "Agent server closed..")
 	logger.Log(0, "Closed DB connection.")
 	logger.Log(0, "Closed DB connection.")

+ 6 - 6
netclient/auth/auth.go

@@ -3,6 +3,7 @@ package auth
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
+	"os"
 
 
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/netclient/config"
 	"github.com/gravitl/netmaker/netclient/config"
@@ -10,7 +11,6 @@ import (
 
 
 	//    "os"
 	//    "os"
 	"context"
 	"context"
-	"io/ioutil"
 
 
 	nodepb "github.com/gravitl/netmaker/grpc"
 	nodepb "github.com/gravitl/netmaker/grpc"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/codes"
@@ -21,13 +21,13 @@ import (
 // SetJWT func will used to create the JWT while signing in and signing out
 // SetJWT func will used to create the JWT while signing in and signing out
 func SetJWT(client nodepb.NodeServiceClient, network string) (context.Context, error) {
 func SetJWT(client nodepb.NodeServiceClient, network string) (context.Context, error) {
 	home := ncutils.GetNetclientPathSpecific()
 	home := ncutils.GetNetclientPathSpecific()
-	tokentext, err := ioutil.ReadFile(home + "nettoken-" + network)
+	tokentext, err := os.ReadFile(home + "nettoken-" + network)
 	if err != nil {
 	if err != nil {
 		err = AutoLogin(client, network)
 		err = AutoLogin(client, network)
 		if err != nil {
 		if err != nil {
 			return nil, status.Errorf(codes.Unauthenticated, fmt.Sprintf("Something went wrong with Auto Login: %v", err))
 			return nil, status.Errorf(codes.Unauthenticated, fmt.Sprintf("Something went wrong with Auto Login: %v", err))
 		}
 		}
-		tokentext, err = ioutil.ReadFile(home + "nettoken-" + network)
+		tokentext, err = os.ReadFile(home + "nettoken-" + network)
 		if err != nil {
 		if err != nil {
 			return nil, status.Errorf(codes.Unauthenticated, fmt.Sprintf("Something went wrong: %v", err))
 			return nil, status.Errorf(codes.Unauthenticated, fmt.Sprintf("Something went wrong: %v", err))
 		}
 		}
@@ -71,7 +71,7 @@ func AutoLogin(client nodepb.NodeServiceClient, network string) error {
 		return err
 		return err
 	}
 	}
 	tokenstring := []byte(res.Data)
 	tokenstring := []byte(res.Data)
-	err = ioutil.WriteFile(home+"nettoken-"+network, tokenstring, 0644)
+	err = os.WriteFile(home+"nettoken-"+network, tokenstring, 0644)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -81,13 +81,13 @@ func AutoLogin(client nodepb.NodeServiceClient, network string) error {
 // StoreSecret - stores auth secret locally
 // StoreSecret - stores auth secret locally
 func StoreSecret(key string, network string) error {
 func StoreSecret(key string, network string) error {
 	d1 := []byte(key)
 	d1 := []byte(key)
-	err := ioutil.WriteFile(ncutils.GetNetclientPathSpecific()+"secret-"+network, d1, 0644)
+	err := os.WriteFile(ncutils.GetNetclientPathSpecific()+"secret-"+network, d1, 0644)
 	return err
 	return err
 }
 }
 
 
 // RetrieveSecret - fetches secret locally
 // RetrieveSecret - fetches secret locally
 func RetrieveSecret(network string) (string, error) {
 func RetrieveSecret(network string) (string, error) {
-	dat, err := ioutil.ReadFile(ncutils.GetNetclientPathSpecific() + "secret-" + network)
+	dat, err := os.ReadFile(ncutils.GetNetclientPathSpecific() + "secret-" + network)
 	return string(dat), err
 	return string(dat), err
 }
 }
 
 

+ 4 - 5
netclient/config/config.go

@@ -6,7 +6,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 
 
@@ -133,12 +132,12 @@ func SaveBackup(network string) error {
 	var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
 	var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
 	var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
 	var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
 	if FileExists(configPath) {
 	if FileExists(configPath) {
-		input, err := ioutil.ReadFile(configPath)
+		input, err := os.ReadFile(configPath)
 		if err != nil {
 		if err != nil {
 			ncutils.Log("failed to read " + configPath + " to make a backup")
 			ncutils.Log("failed to read " + configPath + " to make a backup")
 			return err
 			return err
 		}
 		}
-		if err = ioutil.WriteFile(backupPath, input, 0644); err != nil {
+		if err = os.WriteFile(backupPath, input, 0644); err != nil {
 			ncutils.Log("failed to copy backup to " + backupPath)
 			ncutils.Log("failed to copy backup to " + backupPath)
 			return err
 			return err
 		}
 		}
@@ -151,12 +150,12 @@ func ReplaceWithBackup(network string) error {
 	var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
 	var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
 	var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
 	var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
 	if FileExists(backupPath) {
 	if FileExists(backupPath) {
-		input, err := ioutil.ReadFile(backupPath)
+		input, err := os.ReadFile(backupPath)
 		if err != nil {
 		if err != nil {
 			ncutils.Log("failed to read file " + backupPath + " to backup network: " + network)
 			ncutils.Log("failed to read file " + backupPath + " to backup network: " + network)
 			return err
 			return err
 		}
 		}
-		if err = ioutil.WriteFile(configPath, input, 0644); err != nil {
+		if err = os.WriteFile(configPath, input, 0644); err != nil {
 			ncutils.Log("failed backup " + backupPath + " to " + configPath)
 			ncutils.Log("failed backup " + backupPath + " to " + configPath)
 			return err
 			return err
 		}
 		}

+ 1 - 2
netclient/daemon/macos.go

@@ -2,7 +2,6 @@ package daemon
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -64,7 +63,7 @@ func CreateMacService(servicename string, interval string) error {
 	daemonbytes := []byte(daemonstring)
 	daemonbytes := []byte(daemonstring)
 
 
 	if !ncutils.FileExists("/Library/LaunchDaemons/com.gravitl.netclient.plist") {
 	if !ncutils.FileExists("/Library/LaunchDaemons/com.gravitl.netclient.plist") {
-		err = ioutil.WriteFile("/Library/LaunchDaemons/com.gravitl.netclient.plist", daemonbytes, 0644)
+		err = os.WriteFile("/Library/LaunchDaemons/com.gravitl.netclient.plist", daemonbytes, 0644)
 	}
 	}
 	return err
 	return err
 }
 }

+ 2 - 3
netclient/daemon/systemd.go

@@ -3,7 +3,6 @@ package daemon
 import (
 import (
 	//"github.com/davecgh/go-spew/spew"
 	//"github.com/davecgh/go-spew/spew"
 
 
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -75,7 +74,7 @@ WantedBy=timers.target
 	timerbytes := []byte(systemtimer)
 	timerbytes := []byte(systemtimer)
 
 
 	if !ncutils.FileExists("/etc/systemd/system/netclient.service") {
 	if !ncutils.FileExists("/etc/systemd/system/netclient.service") {
-		err = ioutil.WriteFile("/etc/systemd/system/netclient.service", servicebytes, 0644)
+		err = os.WriteFile("/etc/systemd/system/netclient.service", servicebytes, 0644)
 		if err != nil {
 		if err != nil {
 			log.Println(err)
 			log.Println(err)
 			return err
 			return err
@@ -83,7 +82,7 @@ WantedBy=timers.target
 	}
 	}
 
 
 	if !ncutils.FileExists("/etc/systemd/system/netclient.timer") {
 	if !ncutils.FileExists("/etc/systemd/system/netclient.timer") {
-		err = ioutil.WriteFile("/etc/systemd/system/netclient.timer", timerbytes, 0644)
+		err = os.WriteFile("/etc/systemd/system/netclient.timer", timerbytes, 0644)
 		if err != nil {
 		if err != nil {
 			log.Println(err)
 			log.Println(err)
 			return err
 			return err

+ 1 - 2
netclient/daemon/windows.go

@@ -2,7 +2,6 @@ package daemon
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"strings"
 	"strings"
@@ -57,7 +56,7 @@ func writeServiceConfig() error {
 </service>
 </service>
 `, strings.Replace(ncutils.GetNetclientPathSpecific()+"netclient.exe", `\\`, `\`, -1))
 `, strings.Replace(ncutils.GetNetclientPathSpecific()+"netclient.exe", `\\`, `\`, -1))
 	if !ncutils.FileExists(serviceConfigPath) {
 	if !ncutils.FileExists(serviceConfigPath) {
-		err := ioutil.WriteFile(serviceConfigPath, []byte(scriptString), 0644)
+		err := os.WriteFile(serviceConfigPath, []byte(scriptString), 0644)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}

+ 2 - 2
netclient/functions/join.go

@@ -83,9 +83,9 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
 		}
 		}
 	}
 	}
 	if ncutils.IsLinux() {
 	if ncutils.IsLinux() {
-		_, err := exec.LookPath("resolveconf")
+		_, err := exec.LookPath("resolvconf")
 		if err != nil {
 		if err != nil {
-			ncutils.PrintLog("resolveconf not present", 2)
+			ncutils.PrintLog("resolvconf not present", 2)
 			ncutils.PrintLog("unable to configure DNS automatically, disabling automated DNS management", 2)
 			ncutils.PrintLog("unable to configure DNS automatically, disabling automated DNS management", 2)
 			cfg.Node.DNSOn = "no"
 			cfg.Node.DNSOn = "no"
 		}
 		}

+ 1 - 2
netclient/local/dns.go

@@ -1,7 +1,6 @@
 package local
 package local
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"strings"
 	"strings"
 
 
@@ -14,7 +13,7 @@ import (
 
 
 // SetDNS - sets the DNS of a local machine
 // SetDNS - sets the DNS of a local machine
 func SetDNS(nameserver string) error {
 func SetDNS(nameserver string) error {
-	bytes, err := ioutil.ReadFile("/etc/resolv.conf")
+	bytes, err := os.ReadFile("/etc/resolv.conf")
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 1 - 1
netclient/main.go

@@ -18,7 +18,7 @@ func main() {
 	app := cli.NewApp()
 	app := cli.NewApp()
 	app.Name = "Netclient CLI"
 	app.Name = "Netclient CLI"
 	app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
 	app.Usage = "Netmaker's netclient agent and CLI. Used to perform interactions with Netmaker server and set local WireGuard config."
-	app.Version = "v0.9.2"
+	app.Version = "v0.9.3"
 
 
 	cliFlags := cli_options.GetFlags(ncutils.GetHostname())
 	cliFlags := cli_options.GetFlags(ncutils.GetHostname())
 	app.Commands = cli_options.GetCommands(cliFlags[:])
 	app.Commands = cli_options.GetCommands(cliFlags[:])

+ 2 - 3
netclient/ncutils/netclientutils.go

@@ -5,7 +5,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"math/rand"
 	"math/rand"
 	"net"
 	"net"
@@ -132,7 +131,7 @@ func GetPublicIP() (string, error) {
 		}
 		}
 		defer resp.Body.Close()
 		defer resp.Body.Close()
 		if resp.StatusCode == http.StatusOK {
 		if resp.StatusCode == http.StatusOK {
-			bodyBytes, err := ioutil.ReadAll(resp.Body)
+			bodyBytes, err := io.ReadAll(resp.Body)
 			if err != nil {
 			if err != nil {
 				continue
 				continue
 			}
 			}
@@ -409,7 +408,7 @@ func PrintLog(message string, loglevel int) {
 // GetSystemNetworks - get networks locally
 // GetSystemNetworks - get networks locally
 func GetSystemNetworks() ([]string, error) {
 func GetSystemNetworks() ([]string, error) {
 	var networks []string
 	var networks []string
-	files, err := ioutil.ReadDir(GetNetclientPathSpecific())
+	files, err := os.ReadDir(GetNetclientPathSpecific())
 	if err != nil {
 	if err != nil {
 		return networks, err
 		return networks, err
 	}
 	}

+ 1 - 1
netclient/ncutils/netclientutils_darwin.go

@@ -35,7 +35,7 @@ func GetEmbedded() error {
 }
 }
 
 
 // CreateWireGuardConf - creates a WireGuard conf string
 // CreateWireGuardConf - creates a WireGuard conf string
-func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, dns string, peers []wgtypes.PeerConfig) (string, error) {
+func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, peers []wgtypes.PeerConfig) (string, error) {
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	var listenPortString string
 	var listenPortString string
 	if node.MTU <= 0 {
 	if node.MTU <= 0 {

+ 1 - 1
netclient/ncutils/netclientutils_freebsd.go

@@ -44,7 +44,7 @@ func RunCmd(command string, printerr bool) (string, error) {
 }
 }
 
 
 // CreateWireGuardConf - creates a WireGuard conf string
 // CreateWireGuardConf - creates a WireGuard conf string
-func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, dns string, peers []wgtypes.PeerConfig) (string, error) {
+func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, peers []wgtypes.PeerConfig) (string, error) {
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	var listenPortString string
 	var listenPortString string
 	if node.MTU <= 0 {
 	if node.MTU <= 0 {

+ 1 - 3
netclient/ncutils/netclientutils_linux.go

@@ -34,7 +34,7 @@ func GetEmbedded() error {
 }
 }
 
 
 // CreateWireGuardConf - creates a user space WireGuard conf
 // CreateWireGuardConf - creates a user space WireGuard conf
-func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, dns string, peers []wgtypes.PeerConfig) (string, error) {
+func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, peers []wgtypes.PeerConfig) (string, error) {
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	var listenPortString, postDownString, postUpString string
 	var listenPortString, postDownString, postUpString string
 	if node.MTU <= 0 {
 	if node.MTU <= 0 {
@@ -56,7 +56,6 @@ func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string
 	}
 	}
 	config := fmt.Sprintf(`[Interface]
 	config := fmt.Sprintf(`[Interface]
 Address = %s
 Address = %s
-DNS = %s
 PrivateKey = %s
 PrivateKey = %s
 MTU = %s
 MTU = %s
 %s
 %s
@@ -67,7 +66,6 @@ MTU = %s
 
 
 `,
 `,
 		node.Address+"/32",
 		node.Address+"/32",
-		dns,
 		privatekey,
 		privatekey,
 		strconv.Itoa(int(node.MTU)),
 		strconv.Itoa(int(node.MTU)),
 		postDownString,
 		postDownString,

+ 1 - 1
netclient/ncutils/netclientutils_windows.go

@@ -49,7 +49,7 @@ func RunCmdFormatted(command string, printerr bool) (string, error) {
 }
 }
 
 
 // CreateWireGuardConf - creates a WireGuard conf string
 // CreateWireGuardConf - creates a WireGuard conf string
-func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, dns string, peers []wgtypes.PeerConfig) (string, error) {
+func CreateWireGuardConf(node *models.Node, privatekey string, listenPort string, peers []wgtypes.PeerConfig) (string, error) {
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	peersString, err := parsePeers(node.PersistentKeepalive, peers)
 	var listenPortString string
 	var listenPortString string
 	if node.MTU <= 0 {
 	if node.MTU <= 0 {

+ 2 - 3
netclient/ncwindows/windows.go

@@ -1,7 +1,6 @@
 package ncwindows
 package ncwindows
 
 
 import (
 import (
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 
 
@@ -24,12 +23,12 @@ func InitWindows() {
 
 
 	if os.IsNotExist(dataNetclientErr) { // check and see if netclient.exe is in appdata
 	if os.IsNotExist(dataNetclientErr) { // check and see if netclient.exe is in appdata
 		if currentNetclientErr == nil { // copy it if it exists locally
 		if currentNetclientErr == nil { // copy it if it exists locally
-			input, err := ioutil.ReadFile(wdPath + "\\netclient.exe")
+			input, err := os.ReadFile(wdPath + "\\netclient.exe")
 			if err != nil {
 			if err != nil {
 				log.Println("failed to find netclient.exe")
 				log.Println("failed to find netclient.exe")
 				return
 				return
 			}
 			}
-			if err = ioutil.WriteFile(ncutils.GetNetclientPathSpecific()+"netclient.exe", input, 0644); err != nil {
+			if err = os.WriteFile(ncutils.GetNetclientPathSpecific()+"netclient.exe", input, 0644); err != nil {
 				log.Println("failed to copy netclient.exe to", ncutils.GetNetclientPath())
 				log.Println("failed to copy netclient.exe to", ncutils.GetNetclientPath())
 				return
 				return
 			}
 			}

+ 1 - 1
netclient/netclient.exe.manifest.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
     <assemblyIdentity
     <assemblyIdentity
-            version="0.9.2.0"
+            version="0.9.3.0"
             processorArchitecture="*"
             processorArchitecture="*"
             name="netclient.exe"
             name="netclient.exe"
             type="win32"
             type="win32"

+ 1 - 1
netclient/versioninfo.json

@@ -29,7 +29,7 @@
         "OriginalFilename": "",
         "OriginalFilename": "",
         "PrivateBuild": "",
         "PrivateBuild": "",
         "ProductName": "Netclient",
         "ProductName": "Netclient",
-        "ProductVersion": "v0.9.2.0",
+        "ProductVersion": "v0.9.3.0",
         "SpecialBuild": ""
         "SpecialBuild": ""
     },
     },
     "VarFileInfo": {
     "VarFileInfo": {

+ 8 - 18
netclient/wireguard/common.go

@@ -2,9 +2,8 @@ package wireguard
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"io/ioutil"
 	"log"
 	"log"
-	"os/exec"
+	"os"
 	"runtime"
 	"runtime"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -125,7 +124,6 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 		return err
 		return err
 	}
 	}
 	nodecfg := modcfg.Node
 	nodecfg := modcfg.Node
-	servercfg := modcfg.Server
 
 
 	if err != nil {
 	if err != nil {
 		log.Fatalf("failed to open client: %v", err)
 		log.Fatalf("failed to open client: %v", err)
@@ -142,33 +140,22 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 	if node.Address == "" {
 	if node.Address == "" {
 		log.Fatal("no address to configure")
 		log.Fatal("no address to configure")
 	}
 	}
-	var nameserver string
-	if ncutils.IsLinux() {
-		if _, err := exec.LookPath("resolvconf"); err != nil {
-			ncutils.PrintLog("resolvconf not present", 2)
-			ncutils.PrintLog("unable to configure DNS automatically, disabling automated DNS management", 2)
-			node.DNSOn = "no"
-		}
-	}
-	if node.DNSOn == "yes" {
-		nameserver = servercfg.CoreDNSAddr
-	}
 	var newConf string
 	var newConf string
 	if node.UDPHolePunch != "yes" {
 	if node.UDPHolePunch != "yes" {
-		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), strconv.FormatInt(int64(node.ListenPort), 10), nameserver, peers)
+		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), strconv.FormatInt(int64(node.ListenPort), 10), peers)
 	} else {
 	} else {
-		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), "", nameserver, peers)
+		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), "", peers)
 	}
 	}
 	confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
 	confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
 	ncutils.PrintLog("writing wg conf file to: "+confPath, 1)
 	ncutils.PrintLog("writing wg conf file to: "+confPath, 1)
-	err = ioutil.WriteFile(confPath, []byte(newConf), 0644)
+	err = os.WriteFile(confPath, []byte(newConf), 0644)
 	if err != nil {
 	if err != nil {
 		ncutils.PrintLog("error writing wg conf file to "+confPath+": "+err.Error(), 1)
 		ncutils.PrintLog("error writing wg conf file to "+confPath+": "+err.Error(), 1)
 		return err
 		return err
 	}
 	}
 	if ncutils.IsWindows() {
 	if ncutils.IsWindows() {
 		wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
 		wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
-		err = ioutil.WriteFile(wgConfPath, []byte(newConf), 0644)
+		err = os.WriteFile(wgConfPath, []byte(newConf), 0644)
 		if err != nil {
 		if err != nil {
 			ncutils.PrintLog("error writing wg conf file to "+wgConfPath+": "+err.Error(), 1)
 			ncutils.PrintLog("error writing wg conf file to "+wgConfPath+": "+err.Error(), 1)
 			return err
 			return err
@@ -266,6 +253,9 @@ func SetWGConfig(network string, peerupdate bool) error {
 	} else {
 	} else {
 		err = InitWireguard(&nodecfg, privkey, peers, hasGateway, gateways, false)
 		err = InitWireguard(&nodecfg, privkey, peers, hasGateway, gateways, false)
 	}
 	}
+	if nodecfg.DNSOn == "yes" {
+		_ = local.UpdateDNS(nodecfg.Interface, nodecfg.Network, servercfg.CoreDNSAddr)
+	}
 	return err
 	return err
 }
 }
 
 

+ 3 - 4
netclient/wireguard/unix.go

@@ -2,7 +2,6 @@ package wireguard
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"regexp"
 	"regexp"
@@ -68,7 +67,7 @@ func SyncWGQuickConf(iface string, confPath string) error {
 	}
 	}
 	regex := regexp.MustCompile(".*Warning.*\n")
 	regex := regexp.MustCompile(".*Warning.*\n")
 	conf := regex.ReplaceAllString(confRaw, "")
 	conf := regex.ReplaceAllString(confRaw, "")
-	err = ioutil.WriteFile(tmpConf, []byte(conf), 0644)
+	err = os.WriteFile(tmpConf, []byte(conf), 0644)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -95,12 +94,12 @@ func RemoveWGQuickConf(confPath string, printlog bool) error {
 func StorePrivKey(key string, network string) error {
 func StorePrivKey(key string, network string) error {
 	var err error
 	var err error
 	d1 := []byte(key)
 	d1 := []byte(key)
-	err = ioutil.WriteFile(ncutils.GetNetclientPathSpecific()+"wgkey-"+network, d1, 0644)
+	err = os.WriteFile(ncutils.GetNetclientPathSpecific()+"wgkey-"+network, d1, 0644)
 	return err
 	return err
 }
 }
 
 
 // RetrievePrivKey - reads wg priv key from local disk
 // RetrievePrivKey - reads wg priv key from local disk
 func RetrievePrivKey(network string) (string, error) {
 func RetrievePrivKey(network string) (string, error) {
-	dat, err := ioutil.ReadFile(ncutils.GetNetclientPathSpecific() + "wgkey-" + network)
+	dat, err := os.ReadFile(ncutils.GetNetclientPathSpecific() + "wgkey-" + network)
 	return string(dat), err
 	return string(dat), err
 }
 }

+ 13 - 3
servercfg/serverconf.go

@@ -2,7 +2,7 @@ package servercfg
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"io/ioutil"
+	"io"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -80,6 +80,11 @@ func GetServerConfig() config.ServerConfig {
 	cfg.ClientID = authInfo[1]
 	cfg.ClientID = authInfo[1]
 	cfg.ClientSecret = authInfo[2]
 	cfg.ClientSecret = authInfo[2]
 	cfg.FrontendURL = GetFrontendURL()
 	cfg.FrontendURL = GetFrontendURL()
+	if GetRce() {
+		cfg.RCE = "on"
+	} else {
+		cfg.RCE = "off"
+	}
 
 
 	return cfg
 	return cfg
 }
 }
@@ -108,7 +113,7 @@ func GetAPIConnString() string {
 
 
 // GetVersion - version of netmaker
 // GetVersion - version of netmaker
 func GetVersion() string {
 func GetVersion() string {
-	version := "0.9.2"
+	version := "0.9.3"
 	if config.Config.Server.Version != "" {
 	if config.Config.Server.Version != "" {
 		version = config.Config.Server.Version
 		version = config.Config.Server.Version
 	}
 	}
@@ -412,7 +417,7 @@ func GetPublicIP() (string, error) {
 		}
 		}
 		defer resp.Body.Close()
 		defer resp.Body.Close()
 		if resp.StatusCode == http.StatusOK {
 		if resp.StatusCode == http.StatusOK {
-			bodyBytes, err := ioutil.ReadAll(resp.Body)
+			bodyBytes, err := io.ReadAll(resp.Body)
 			if err != nil {
 			if err != nil {
 				continue
 				continue
 			}
 			}
@@ -528,3 +533,8 @@ func getMacAddr() string {
 	}
 	}
 	return as[0]
 	return as[0]
 }
 }
+
+// GetRce - sees if Rce is enabled, off by default
+func GetRce() bool {
+	return os.Getenv("RCE") == "on" || config.Config.Server.RCE == "on"
+}