all: update to Go 1.18

Bump go.mod and README.

Switch to upstream net/netip.

Use strings.Cut.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2022-03-16 16:09:48 -07:00
parent ae6bc4dd64
commit 42c9af45e1
20 changed files with 23 additions and 33 deletions

View File

@ -46,7 +46,7 @@ This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapp
## Building ## Building
This requires an installation of [go](https://golang.org) ≥ 1.17. This requires an installation of [go](https://golang.org) ≥ 1.18.
``` ```
$ git clone https://git.zx2c4.com/wireguard-go $ git clone https://git.zx2c4.com/wireguard-go

View File

@ -8,13 +8,13 @@ package conn
import ( import (
"errors" "errors"
"net" "net"
"net/netip"
"strconv" "strconv"
"sync" "sync"
"syscall" "syscall"
"unsafe" "unsafe"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"golang.zx2c4.com/go118/netip"
) )
type ipv4Source struct { type ipv4Source struct {

View File

@ -8,10 +8,9 @@ package conn
import ( import (
"errors" "errors"
"net" "net"
"net/netip"
"sync" "sync"
"syscall" "syscall"
"golang.zx2c4.com/go118/netip"
) )
// StdNetBind is meant to be a temporary solution on platforms for which // StdNetBind is meant to be a temporary solution on platforms for which

View File

@ -9,13 +9,13 @@ import (
"encoding/binary" "encoding/binary"
"io" "io"
"net" "net"
"net/netip"
"strconv" "strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
"unsafe" "unsafe"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn/winrio" "golang.zx2c4.com/wireguard/conn/winrio"
) )

View File

@ -9,9 +9,9 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"net" "net"
"net/netip"
"os" "os"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/conn"
) )

View File

@ -9,11 +9,10 @@ package conn
import ( import (
"errors" "errors"
"fmt" "fmt"
"net/netip"
"reflect" "reflect"
"runtime" "runtime"
"strings" "strings"
"golang.zx2c4.com/go118/netip"
) )
// A ReceiveFunc receives a single inbound packet from the network. // A ReceiveFunc receives a single inbound packet from the network.

View File

@ -11,10 +11,9 @@ import (
"errors" "errors"
"math/bits" "math/bits"
"net" "net"
"net/netip"
"sync" "sync"
"unsafe" "unsafe"
"golang.zx2c4.com/go118/netip"
) )
type parentIndirection struct { type parentIndirection struct {

View File

@ -8,10 +8,9 @@ package device
import ( import (
"math/rand" "math/rand"
"net" "net"
"net/netip"
"sort" "sort"
"testing" "testing"
"golang.zx2c4.com/go118/netip"
) )
const ( const (

View File

@ -8,9 +8,8 @@ package device
import ( import (
"math/rand" "math/rand"
"net" "net"
"net/netip"
"testing" "testing"
"golang.zx2c4.com/go118/netip"
) )
type testPairCommonBits struct { type testPairCommonBits struct {

View File

@ -11,6 +11,7 @@ import (
"fmt" "fmt"
"io" "io"
"math/rand" "math/rand"
"net/netip"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"sync" "sync"
@ -18,7 +19,6 @@ import (
"testing" "testing"
"time" "time"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/conn/bindtest" "golang.zx2c4.com/wireguard/conn/bindtest"
"golang.zx2c4.com/wireguard/tun/tuntest" "golang.zx2c4.com/wireguard/tun/tuntest"

View File

@ -7,8 +7,7 @@ package device
import ( import (
"math/rand" "math/rand"
"net/netip"
"golang.zx2c4.com/go118/netip"
) )
type DummyEndpoint struct { type DummyEndpoint struct {

View File

@ -12,13 +12,13 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"net/netip"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/ipc" "golang.zx2c4.com/wireguard/ipc"
) )
@ -161,12 +161,10 @@ func (device *Device) IpcSetOperation(r io.Reader) (err error) {
peer.handlePostConfig() peer.handlePostConfig()
return nil return nil
} }
parts := strings.Split(line, "=") key, value, ok := strings.Cut(line, "=")
if len(parts) != 2 { if !ok {
return ipcErrorf(ipc.IpcErrorProtocol, "failed to parse line %q, found %d =-separated parts, want 2", line, len(parts)) return ipcErrorf(ipc.IpcErrorProtocol, "failed to parse line %q", line)
} }
key := parts[0]
value := parts[1]
if key == "public_key" { if key == "public_key" {
if deviceConfig { if deviceConfig {

2
go.mod
View File

@ -1,6 +1,6 @@
module golang.zx2c4.com/wireguard module golang.zx2c4.com/wireguard
go 1.17 go 1.18
require ( require (
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa

View File

@ -6,10 +6,9 @@
package ratelimiter package ratelimiter
import ( import (
"net/netip"
"sync" "sync"
"time" "time"
"golang.zx2c4.com/go118/netip"
) )
const ( const (

View File

@ -6,10 +6,9 @@
package ratelimiter package ratelimiter
import ( import (
"net/netip"
"testing" "testing"
"time" "time"
"golang.zx2c4.com/go118/netip"
) )
type result struct { type result struct {

View File

@ -12,8 +12,8 @@ import (
"io" "io"
"log" "log"
"net/http" "net/http"
"net/netip"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/tun/netstack" "golang.zx2c4.com/wireguard/tun/netstack"

View File

@ -13,8 +13,8 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"net/netip"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/tun/netstack" "golang.zx2c4.com/wireguard/tun/netstack"

View File

@ -12,12 +12,12 @@ import (
"bytes" "bytes"
"log" "log"
"math/rand" "math/rand"
"net/netip"
"time" "time"
"golang.org/x/net/icmp" "golang.org/x/net/icmp"
"golang.org/x/net/ipv4" "golang.org/x/net/ipv4"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/conn"
"golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/tun/netstack" "golang.zx2c4.com/wireguard/tun/netstack"

View File

@ -13,13 +13,13 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"net/netip"
"os" "os"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/tun" "golang.zx2c4.com/wireguard/tun"
"golang.org/x/net/dns/dnsmessage" "golang.org/x/net/dns/dnsmessage"

View File

@ -8,9 +8,9 @@ package tuntest
import ( import (
"encoding/binary" "encoding/binary"
"io" "io"
"net/netip"
"os" "os"
"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/tun" "golang.zx2c4.com/wireguard/tun"
) )