mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-16 13:51:42 +08:00
updated ioutil refs and composes
This commit is contained in:
2
.github/workflows/buildandrelease.yml
vendored
2
.github/workflows/buildandrelease.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
4
.github/workflows/test-artifacts.yml
vendored
4
.github/workflows/test-artifacts.yml
vendored
@@ -12,6 +12,10 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -11,6 +11,10 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
- name: run tests
|
||||
run: |
|
||||
go test -p 1 ./... -v
|
||||
|
@@ -3,7 +3,7 @@ package auth
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"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())
|
||||
}
|
||||
defer response.Body.Close()
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
contents, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed reading response body: %s", err.Error())
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package auth
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"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())
|
||||
}
|
||||
defer response.Body.Close()
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
contents, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed reading response body: %s", err.Error())
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package auth
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"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())
|
||||
}
|
||||
defer response.Body.Close()
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
contents, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed reading response body: %s", err.Error())
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ version: "3.4"
|
||||
services:
|
||||
netmaker:
|
||||
container_name: netmaker
|
||||
image: gravitl/netmaker:v0.9.2
|
||||
image: gravitl/netmaker:v0.9.3
|
||||
volumes:
|
||||
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
|
||||
- /run/systemd/system:/run/systemd/system
|
||||
@@ -40,7 +40,7 @@ services:
|
||||
container_name: netmaker-ui
|
||||
depends_on:
|
||||
- netmaker
|
||||
image: gravitl/netmaker-ui:v0.9.2
|
||||
image: gravitl/netmaker-ui:v0.9.3
|
||||
links:
|
||||
- "netmaker:api"
|
||||
ports:
|
||||
|
@@ -3,7 +3,7 @@ version: "3.4"
|
||||
services:
|
||||
netmaker:
|
||||
container_name: netmaker
|
||||
image: gravitl/netmaker:v0.9.2
|
||||
image: gravitl/netmaker:v0.9.3
|
||||
volumes:
|
||||
- dnsconfig:/root/config/dnsconfig
|
||||
- /usr/bin/wg:/usr/bin/wg
|
||||
@@ -38,7 +38,7 @@ services:
|
||||
container_name: netmaker-ui
|
||||
depends_on:
|
||||
- netmaker
|
||||
image: gravitl/netmaker-ui:v0.9.2
|
||||
image: gravitl/netmaker-ui:v0.9.3
|
||||
links:
|
||||
- "netmaker:api"
|
||||
ports:
|
||||
|
@@ -3,7 +3,7 @@ version: "3.4"
|
||||
services:
|
||||
netmaker:
|
||||
container_name: netmaker
|
||||
image: gravitl/netmaker:v0.9.2
|
||||
image: gravitl/netmaker:v0.9.3
|
||||
volumes:
|
||||
- /usr/bin/wg:/usr/bin/wg
|
||||
- sqldata:/root/data
|
||||
@@ -36,7 +36,7 @@ services:
|
||||
container_name: netmaker-ui
|
||||
depends_on:
|
||||
- netmaker
|
||||
image: gravitl/netmaker-ui:v0.9.2
|
||||
image: gravitl/netmaker-ui:v0.9.3
|
||||
links:
|
||||
- "netmaker:api"
|
||||
ports:
|
||||
|
@@ -11,7 +11,7 @@ services:
|
||||
container_name: netmaker
|
||||
depends_on:
|
||||
- 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)
|
||||
- dnsconfig:/root/config/dnsconfig # Netmaker writes Corefile to this location, which gets mounted by CoreDNS for DNS configuration.
|
||||
- /usr/bin/wg:/usr/bin/wg
|
||||
@@ -41,7 +41,7 @@ services:
|
||||
container_name: netmaker-ui
|
||||
depends_on:
|
||||
- netmaker
|
||||
image: gravitl/netmaker-ui:v0.9.2
|
||||
image: gravitl/netmaker-ui:v0.9.3
|
||||
links:
|
||||
- "netmaker:api"
|
||||
ports:
|
||||
|
@@ -3,7 +3,7 @@ version: "3.4"
|
||||
services:
|
||||
netmaker:
|
||||
container_name: netmaker
|
||||
image: gravitl/netmaker:v0.9.0
|
||||
image: gravitl/netmaker:v0.9.3
|
||||
volumes:
|
||||
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
|
||||
- /run/systemd/system:/run/systemd/system
|
||||
@@ -40,7 +40,7 @@ services:
|
||||
container_name: netmaker-ui
|
||||
depends_on:
|
||||
- netmaker
|
||||
image: gravitl/netmaker-ui:v0.9.2
|
||||
image: gravitl/netmaker-ui:v0.9.3
|
||||
links:
|
||||
- "netmaker:api"
|
||||
ports:
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -200,7 +199,7 @@ func TestSetDNS(t *testing.T) {
|
||||
info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
|
||||
assert.Nil(t, err)
|
||||
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.Contains(t, string(content), "testnode.skynet")
|
||||
})
|
||||
@@ -212,7 +211,7 @@ func TestSetDNS(t *testing.T) {
|
||||
info, err := os.Stat("./config/dnsconfig/netmaker.hosts")
|
||||
assert.Nil(t, err)
|
||||
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.Contains(t, string(content), "newhost.skynet")
|
||||
})
|
||||
|
@@ -2,7 +2,6 @@ package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -90,7 +89,7 @@ func DumpFile(filePath string) {
|
||||
|
||||
// Retrieve - retrieves logs from given file
|
||||
func Retrieve(filePath string) string {
|
||||
contents, err := ioutil.ReadFile(filePath)
|
||||
contents, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
@@ -135,7 +134,7 @@ func SetCorefile(domains string) error {
|
||||
`
|
||||
corebytes := []byte(corefile)
|
||||
|
||||
err = ioutil.WriteFile(dir+"/config/dnsconfig/Corefile", corebytes, 0644)
|
||||
err = os.WriteFile(dir+"/config/dnsconfig/Corefile", corebytes, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package logic
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"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)
|
||||
confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
|
||||
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 {
|
||||
logger.Log(1, "error writing wg conf file to", confPath, ":", err.Error())
|
||||
return err
|
||||
@@ -97,7 +96,7 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
||||
if ncutils.IsWindows() {
|
||||
wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
|
||||
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 {
|
||||
logger.Log(1, "error writing wg conf file to", wgConfPath, ":", err.Error())
|
||||
return err
|
||||
|
@@ -3,6 +3,7 @@ package auth
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"github.com/gravitl/netmaker/netclient/config"
|
||||
@@ -10,7 +11,6 @@ import (
|
||||
|
||||
// "os"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
|
||||
nodepb "github.com/gravitl/netmaker/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
// SetJWT func will used to create the JWT while signing in and signing out
|
||||
func SetJWT(client nodepb.NodeServiceClient, network string) (context.Context, error) {
|
||||
home := ncutils.GetNetclientPathSpecific()
|
||||
tokentext, err := ioutil.ReadFile(home + "nettoken-" + network)
|
||||
tokentext, err := os.ReadFile(home + "nettoken-" + network)
|
||||
if err != nil {
|
||||
err = AutoLogin(client, network)
|
||||
if err != nil {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
tokenstring := []byte(res.Data)
|
||||
err = ioutil.WriteFile(home+"nettoken-"+network, tokenstring, 0644)
|
||||
err = os.WriteFile(home+"nettoken-"+network, tokenstring, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,13 +81,13 @@ func AutoLogin(client nodepb.NodeServiceClient, network string) error {
|
||||
// StoreSecret - stores auth secret locally
|
||||
func StoreSecret(key string, network string) error {
|
||||
d1 := []byte(key)
|
||||
err := ioutil.WriteFile(ncutils.GetNetclientPathSpecific()+"secret-"+network, d1, 0644)
|
||||
err := os.WriteFile(ncutils.GetNetclientPathSpecific()+"secret-"+network, d1, 0644)
|
||||
return err
|
||||
}
|
||||
|
||||
// RetrieveSecret - fetches secret locally
|
||||
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
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -133,12 +132,12 @@ func SaveBackup(network string) error {
|
||||
var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
|
||||
var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
|
||||
if FileExists(configPath) {
|
||||
input, err := ioutil.ReadFile(configPath)
|
||||
input, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
ncutils.Log("failed to read " + configPath + " to make a backup")
|
||||
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)
|
||||
return err
|
||||
}
|
||||
@@ -151,12 +150,12 @@ func ReplaceWithBackup(network string) error {
|
||||
var backupPath = ncutils.GetNetclientPathSpecific() + "backup.netconfig-" + network
|
||||
var configPath = ncutils.GetNetclientPathSpecific() + "netconfig-" + network
|
||||
if FileExists(backupPath) {
|
||||
input, err := ioutil.ReadFile(backupPath)
|
||||
input, err := os.ReadFile(backupPath)
|
||||
if err != nil {
|
||||
ncutils.Log("failed to read file " + backupPath + " to backup network: " + network)
|
||||
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)
|
||||
return err
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package daemon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -64,7 +63,7 @@ func CreateMacService(servicename string, interval string) error {
|
||||
daemonbytes := []byte(daemonstring)
|
||||
|
||||
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
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package daemon
|
||||
import (
|
||||
//"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -75,7 +74,7 @@ WantedBy=timers.target
|
||||
timerbytes := []byte(systemtimer)
|
||||
|
||||
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 {
|
||||
log.Println(err)
|
||||
return err
|
||||
@@ -83,7 +82,7 @@ WantedBy=timers.target
|
||||
}
|
||||
|
||||
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 {
|
||||
log.Println(err)
|
||||
return err
|
||||
|
@@ -2,7 +2,6 @@ package daemon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -57,7 +56,7 @@ func writeServiceConfig() error {
|
||||
</service>
|
||||
`, strings.Replace(ncutils.GetNetclientPathSpecific()+"netclient.exe", `\\`, `\`, -1))
|
||||
if !ncutils.FileExists(serviceConfigPath) {
|
||||
err := ioutil.WriteFile(serviceConfigPath, []byte(scriptString), 0644)
|
||||
err := os.WriteFile(serviceConfigPath, []byte(scriptString), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -14,7 +13,7 @@ import (
|
||||
|
||||
// SetDNS - sets the DNS of a local machine
|
||||
func SetDNS(nameserver string) error {
|
||||
bytes, err := ioutil.ReadFile("/etc/resolv.conf")
|
||||
bytes, err := os.ReadFile("/etc/resolv.conf")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
@@ -132,7 +131,7 @@ func GetPublicIP() (string, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -409,7 +408,7 @@ func PrintLog(message string, loglevel int) {
|
||||
// GetSystemNetworks - get networks locally
|
||||
func GetSystemNetworks() ([]string, error) {
|
||||
var networks []string
|
||||
files, err := ioutil.ReadDir(GetNetclientPathSpecific())
|
||||
files, err := os.ReadDir(GetNetclientPathSpecific())
|
||||
if err != nil {
|
||||
return networks, err
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package ncwindows
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -24,12 +23,12 @@ func InitWindows() {
|
||||
|
||||
if os.IsNotExist(dataNetclientErr) { // check and see if netclient.exe is in appdata
|
||||
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 {
|
||||
log.Println("failed to find netclient.exe")
|
||||
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())
|
||||
return
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ package wireguard
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -142,14 +142,14 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
||||
}
|
||||
confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
|
||||
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 {
|
||||
ncutils.PrintLog("error writing wg conf file to "+confPath+": "+err.Error(), 1)
|
||||
return err
|
||||
}
|
||||
if ncutils.IsWindows() {
|
||||
wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
|
||||
err = ioutil.WriteFile(wgConfPath, []byte(newConf), 0644)
|
||||
err = os.WriteFile(wgConfPath, []byte(newConf), 0644)
|
||||
if err != nil {
|
||||
ncutils.PrintLog("error writing wg conf file to "+wgConfPath+": "+err.Error(), 1)
|
||||
return err
|
||||
|
@@ -2,7 +2,6 @@ package wireguard
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -68,7 +67,7 @@ func SyncWGQuickConf(iface string, confPath string) error {
|
||||
}
|
||||
regex := regexp.MustCompile(".*Warning.*\n")
|
||||
conf := regex.ReplaceAllString(confRaw, "")
|
||||
err = ioutil.WriteFile(tmpConf, []byte(conf), 0644)
|
||||
err = os.WriteFile(tmpConf, []byte(conf), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -95,12 +94,12 @@ func RemoveWGQuickConf(confPath string, printlog bool) error {
|
||||
func StorePrivKey(key string, network string) error {
|
||||
var err error
|
||||
d1 := []byte(key)
|
||||
err = ioutil.WriteFile(ncutils.GetNetclientPathSpecific()+"wgkey-"+network, d1, 0644)
|
||||
err = os.WriteFile(ncutils.GetNetclientPathSpecific()+"wgkey-"+network, d1, 0644)
|
||||
return err
|
||||
}
|
||||
|
||||
// RetrievePrivKey - reads wg priv key from local disk
|
||||
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
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package servercfg
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -417,7 +417,7 @@ func GetPublicIP() (string, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user