Skip to content

Commit 8ef7fa0

Browse files
authored
Merge pull request #34 from SLoeuillet/go-refresh
Bump go version and fix some deprecations
2 parents 33d75ab + 15b09bf commit 8ef7fa0

10 files changed

Lines changed: 103 additions & 185 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ typescript-axios-client:
3939
-i openapi-spec.yaml \
4040
-o clients/typeascript-axios
4141

42-
.PHONY: clean build install
42+
.PHONY: clean build install

go.mod

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
module github.com/suquant/wgrest
22

3-
go 1.16
3+
go 1.21
44

55
require (
6-
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
76
github.com/glendc/go-external-ip v0.1.0
8-
github.com/labstack/echo/v4 v4.6.1
9-
github.com/labstack/gommon v0.3.1 // indirect
7+
github.com/labstack/echo/v4 v4.11.3
108
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
11-
github.com/urfave/cli/v2 v2.3.0
12-
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
13-
golang.org/x/net v0.0.0-20211111160137-58aab5ef257a // indirect
14-
golang.org/x/sys v0.0.0-20211112143042-c6105e7cf70d // indirect
15-
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
16-
golang.zx2c4.com/wireguard v0.0.0-20211111141719-cad0ff2cfbd9 // indirect
17-
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211109202428-0073765f69ba
9+
github.com/urfave/cli/v2 v2.25.7
10+
golang.org/x/crypto v0.16.0
11+
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
12+
)
13+
14+
require (
15+
github.com/BurntSushi/toml v1.3.2 // indirect
16+
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
17+
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
18+
github.com/google/go-cmp v0.6.0 // indirect
19+
github.com/josharian/native v1.1.0 // indirect
20+
github.com/labstack/gommon v0.4.1 // indirect
21+
github.com/mattn/go-colorable v0.1.13 // indirect
22+
github.com/mattn/go-isatty v0.0.20 // indirect
23+
github.com/mdlayher/genetlink v1.3.2 // indirect
24+
github.com/mdlayher/netlink v1.7.2 // indirect
25+
github.com/mdlayher/socket v0.5.0 // indirect
26+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
27+
github.com/valyala/bytebufferpool v1.0.0 // indirect
28+
github.com/valyala/fasttemplate v1.2.2 // indirect
29+
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
30+
golang.org/x/net v0.19.0 // indirect
31+
golang.org/x/sync v0.5.0 // indirect
32+
golang.org/x/sys v0.15.0 // indirect
33+
golang.org/x/text v0.14.0 // indirect
34+
golang.org/x/time v0.5.0 // indirect
35+
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect
36+
gopkg.in/yaml.v3 v3.0.1 // indirect
1837
)

go.sum

Lines changed: 51 additions & 158 deletions
Large diffs are not rendered by default.

handlers/api_device.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ package handlers
22

33
import (
44
"bytes"
5+
"io"
6+
"net/http"
7+
"net/url"
8+
"os"
9+
"strconv"
10+
511
"github.com/labstack/echo/v4"
612
"github.com/skip2/go-qrcode"
713
"github.com/suquant/wgrest/models"
814
"github.com/suquant/wgrest/storage"
915
"github.com/suquant/wgrest/utils"
1016
"golang.zx2c4.com/wireguard/wgctrl"
1117
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
12-
"io"
13-
"net/http"
14-
"net/url"
15-
"os"
16-
"strconv"
1718
)
1819

1920
// CreateDevice - Create new device

models/model_peer_ext.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package models
33
import (
44
"encoding/base64"
55
"fmt"
6-
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
76
"net"
87
"time"
8+
9+
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
910
)
1011

1112
var (

storage/file_storage.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package storage
22

33
import (
44
"encoding/base64"
5-
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
6-
"io/ioutil"
75
"os"
86
"path"
7+
8+
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
99
)
1010

1111
type FileStorage struct {
@@ -26,7 +26,7 @@ func (s *FileStorage) getFilePath(name string) string {
2626

2727
func (s *FileStorage) WriteDeviceOptions(name string, options StoreDeviceOptions) error {
2828
filePath := s.getFilePath(name)
29-
f, err := ioutil.TempFile(s.dir, name)
29+
f, err := os.CreateTemp(s.dir, name)
3030
if err != nil {
3131
return err
3232
}
@@ -46,7 +46,7 @@ func (s *FileStorage) WriteDeviceOptions(name string, options StoreDeviceOptions
4646
func (s *FileStorage) WritePeerOptions(pubKey wgtypes.Key, options StorePeerOptions) error {
4747
safeName := base64.URLEncoding.EncodeToString(pubKey[:])
4848
filePath := s.getFilePath(safeName)
49-
f, err := ioutil.TempFile(s.dir, safeName)
49+
f, err := os.CreateTemp(s.dir, safeName)
5050
if err != nil {
5151
return err
5252
}

storage/storage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package storage
33
import (
44
"bufio"
55
"fmt"
6-
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
76
"io"
87
"strings"
8+
9+
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
910
)
1011

1112
type StoreDeviceOptions struct {

utils/peers_filter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package utils
22

33
import (
4+
"strings"
5+
46
"github.com/suquant/wgrest/models"
57
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
6-
"strings"
78
)
89

910
func FilterPeersByQuery(q string, peers []wgtypes.Peer) []wgtypes.Peer {

utils/peers_sort.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package utils
33
import (
44
"bytes"
55
"fmt"
6-
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
76
"sort"
7+
8+
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
89
)
910

1011
type sortPeerByPubKey []wgtypes.Peer

utils/quick_config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package utils
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/suquant/wgrest/models"
7-
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
86
"io"
97
"strings"
8+
9+
"github.com/suquant/wgrest/models"
10+
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
1011
)
1112

1213
type PeerQuickConfigOptions struct {

0 commit comments

Comments
 (0)