Browse Source

updated ioutil refs and composes

0xdcarns 3 years ago
parent
commit
43b9e73eaa

+ 1 - 1
.github/workflows/buildandrelease.yml

@@ -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: |

+ 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 - 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:

+ 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")
 	})
 	})

+ 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
 	}
 	}

+ 2 - 3
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"
@@ -89,7 +88,7 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 		newConf, _ = ncutils.CreateWireGuardConf(node, key.String(), strconv.FormatInt(int64(node.ListenPort), 10), 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
@@ -97,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

+ 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
 		}
 		}

+ 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
 	}
 	}

+ 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
 	}
 	}

+ 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
 			}
 			}

+ 3 - 3
netclient/wireguard/common.go

@@ -2,8 +2,8 @@ package wireguard
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"io/ioutil"
 	"log"
 	"log"
+	"os"
 	"runtime"
 	"runtime"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -142,14 +142,14 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 	}
 	}
 	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

+ 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
 }
 }

+ 2 - 2
servercfg/serverconf.go

@@ -2,7 +2,7 @@ package servercfg
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"io/ioutil"
+	"io"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -417,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
 			}
 			}