Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD kernel support #128

Merged
merged 10 commits into from
Nov 4, 2022
Prev Previous commit
Next Next commit
internal/wguser: Replace deprecated io/ioutil package with io
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
  • Loading branch information
stv0g committed Oct 11, 2022
commit f83f6484a4a211ac09a0283df6729d5054051ada
6 changes: 3 additions & 3 deletions internal/wguser/conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package wguser

import (
"errors"
"io/ioutil"
"io/fs"
"net"
"os"
"path/filepath"
Expand All @@ -29,7 +29,7 @@ func find() ([]string, error) {
func findUNIXSockets(dirs []string) ([]string, error) {
var socks []string
for _, d := range dirs {
files, err := ioutil.ReadDir(d)
files, err := os.ReadDir(d)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
continue
Expand All @@ -39,7 +39,7 @@ func findUNIXSockets(dirs []string) ([]string, error) {
}

for _, f := range files {
if f.Mode()&os.ModeSocket == 0 {
if f.Type()&fs.ModeSocket == 0 {
continue
}

Expand Down
7 changes: 3 additions & 4 deletions internal/wguser/conn_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package wguser

import (
"io/ioutil"
"net"
"os"
"path/filepath"
Expand All @@ -14,14 +13,14 @@ import (
)

func TestUNIX_findUNIXSockets(t *testing.T) {
tmp, err := ioutil.TempDir(os.TempDir(), "wireguardcfg-test")
tmp, err := os.MkdirTemp(os.TempDir(), "wireguardcfg-test")
if err != nil {
t.Fatalf("failed to create temporary directory: %v", err)
}
defer os.RemoveAll(tmp)

// Create a file which is not a device socket.
f, err := ioutil.TempFile(tmp, "notwg")
f, err := os.CreateTemp(tmp, "notwg")
if err != nil {
t.Fatalf("failed to create temporary file: %v", err)
}
Expand Down Expand Up @@ -63,7 +62,7 @@ func testFind(dir string) func() ([]string, error) {
func testListen(t *testing.T, device string) (l net.Listener, dir string, done func()) {
t.Helper()

tmp, err := ioutil.TempDir(os.TempDir(), "wguser-test")
tmp, err := os.MkdirTemp(os.TempDir(), "wguser-test")
if err != nil {
t.Fatalf("failed to create temporary directory: %v", err)
}
Expand Down