mirror of
https://github.com/davegallant/vpngate.git
synced 2025-08-06 00:33:40 +00:00
Remove use of ioutil package (#93)
This commit is contained in:
@@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -29,6 +28,7 @@ func init() {
|
||||
|
||||
var connectCmd = &cobra.Command{
|
||||
Use: "connect",
|
||||
|
||||
Short: "Connect to a vpn server (survey selection appears if hostname is not provided)",
|
||||
Long: `Connect to a vpn from a list of relay servers`,
|
||||
Args: cobra.RangeArgs(0, 1),
|
||||
@@ -91,7 +91,7 @@ var connectCmd = &cobra.Command{
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "vpngate-openvpn-config-")
|
||||
tmpfile, err := os.CreateTemp("", "vpngate-openvpn-config-")
|
||||
if err != nil {
|
||||
log.Fatal().Msgf(err.Error())
|
||||
os.Exit(1)
|
||||
|
@@ -2,7 +2,7 @@ package vpn
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
@@ -36,7 +36,7 @@ func getVpnListCache() (*[]Server, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
byteValue, err := ioutil.ReadAll(serversFile)
|
||||
byteValue, err := io.ReadAll(serversFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func writeVpnListToCache(servers []Server) error {
|
||||
|
||||
cacheFile := path.Join(getCacheDir(), serverCachefile)
|
||||
|
||||
err = ioutil.WriteFile(cacheFile, f, 0o644)
|
||||
err = os.WriteFile(cacheFile, f, 0o644)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package vpn
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/davegallant/vpngate/pkg/exec"
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
|
||||
// Connect to a specified OpenVPN configuration
|
||||
func Connect(configPath string) error {
|
||||
tmpLogFile, err := ioutil.TempFile("", "vpngate-openvpn-log-")
|
||||
tmpLogFile, err := os.CreateTemp("", "vpngate-openvpn-log-")
|
||||
if err != nil {
|
||||
return errors.Annotate(err, "Unable to create a temporary log file")
|
||||
}
|
||||
|
Reference in New Issue
Block a user