Skip to content

Commit

Permalink
Update for Go 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
luker983 committed Oct 19, 2023
1 parent 0b6d6e5 commit c6736ec
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module wiretap

go 1.20

replace golang.zx2c4.com/wireguard => github.com/luker983/wireguard-go v0.0.0-20230628150900-2e22d4a23db1
replace golang.zx2c4.com/wireguard => github.com/luker983/wireguard-go v0.0.0-20231019223227-fc689040dc0a

require (
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
Expand All @@ -17,7 +17,7 @@ require (
golang.org/x/net v0.17.0
golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb
gvisor.dev/gvisor v0.0.0-20221203005347-703fd9b7fbc0
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259
)

require (
Expand All @@ -37,7 +37,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.1.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/libp2p/go-reuseport v0.2.0 h1:18PRvIMlpY6ZK85nIAicSBuXXvrYoSw3dsBAR7zc560=
github.com/libp2p/go-reuseport v0.2.0/go.mod h1:bvVho6eLMm6Bz5hmU0LYN3ixd3nPPvtIlaURZZgOY4k=
github.com/luker983/wireguard-go v0.0.0-20230628150900-2e22d4a23db1 h1:+Tr/ZJIEOLVxTNqt2yv0b8l2CONqPfot4511omlEgks=
github.com/luker983/wireguard-go v0.0.0-20230628150900-2e22d4a23db1/go.mod h1:tqur9LnfstdR9ep2LaJT4lFUl0EjlHtge+gAjmsHUG4=
github.com/luker983/wireguard-go v0.0.0-20231019223227-fc689040dc0a h1:gUjN6KFTeYzhwiT2qaf2kRLJhfi5+/yvqxeKYg8vHuA=
github.com/luker983/wireguard-go v0.0.0-20231019223227-fc689040dc0a/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA=
github.com/m1gwings/treedrawer v0.3.3-beta h1:VeeQ4I90+NL0G2Tga3H4EY4hbOyVP3ID4T93r21oLbQ=
github.com/m1gwings/treedrawer v0.3.3-beta/go.mod h1:Sebh5tCtjQWAG/B9xWct163vB9pCbBcA1ykaUErDUTY=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
Expand Down Expand Up @@ -307,8 +307,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -517,8 +517,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gvisor.dev/gvisor v0.0.0-20221203005347-703fd9b7fbc0 h1:Wobr37noukisGxpKo5jAsLREcpj61RxrWYzD8uwveOY=
gvisor.dev/gvisor v0.0.0-20221203005347-703fd9b7fbc0/go.mod h1:Dn5idtptoW1dIos9U6A2rpebLs/MtTwFacjKb8jLdQA=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 h1:TbRPT0HtzFP3Cno1zZo7yPzEEnfu8EjLfl6IU9VfqkQ=
gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259/go.mod h1:AVgIgHMwK63XvmAzWG9vLQ41YnVHN0du0tEC46fI7yY=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
8 changes: 4 additions & 4 deletions src/transport/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func Handle(tnet *netstack.Net, devRelay *device.Device, devE2EE *device.Device,

localAddr := tcpip.FullAddress{
NIC: 1,
Addr: tcpip.Address(addr.AsSlice()),
Addr: tcpip.AddrFromSlice(addr.AsSlice()),
}

http.HandleFunc("/ping", wrapApi(handlePing()))
Expand Down Expand Up @@ -443,7 +443,7 @@ func handleExpose(tnet *netstack.Net, exposeMap *map[ExposeTuple]ExposeConn, exp
tnet.Stack(),
&l,
localAddr,
tcpip.FullAddress{NIC: 1, Addr: tcpip.Address(et.RemoteAddr.AsSlice())},
tcpip.FullAddress{NIC: 1, Addr: tcpip.AddrFromSlice(et.RemoteAddr.AsSlice())},
proto,
)

Expand All @@ -461,7 +461,7 @@ func handleExpose(tnet *netstack.Net, exposeMap *map[ExposeTuple]ExposeConn, exp
tnet.Stack(),
l,
localAddr,
tcpip.FullAddress{NIC: 1, Addr: tcpip.Address(et.RemoteAddr.AsSlice()), Port: uint16(et.LocalPort)},
tcpip.FullAddress{NIC: 1, Addr: tcpip.AddrFromSlice(et.RemoteAddr.AsSlice()), Port: uint16(et.LocalPort)},
proto,
)

Expand All @@ -484,7 +484,7 @@ func handleExpose(tnet *netstack.Net, exposeMap *map[ExposeTuple]ExposeConn, exp
tnet.Stack(),
c,
localAddr,
tcpip.FullAddress{NIC: 1, Addr: tcpip.Address(et.RemoteAddr.AsSlice()), Port: uint16(et.LocalPort)},
tcpip.FullAddress{NIC: 1, Addr: tcpip.AddrFromSlice(et.RemoteAddr.AsSlice()), Port: uint16(et.LocalPort)},
proto,
)

Expand Down
2 changes: 1 addition & 1 deletion src/transport/icmp/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func sendEchoResponse(s *stack.Stack, pkt header.Network) {
var ipHeader []byte
var err error

isIpv6 := pkt.DestinationAddress().To4() == ""
isIpv6 := pkt.DestinationAddress().To4() == tcpip.Address{}

netProto := ipv4.ProtocolNumber
if isIpv6 {
Expand Down
2 changes: 1 addition & 1 deletion src/transport/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Handler(c Config) func(*tcp.ForwarderRequest) {
log.Printf("(client %s) - Transport: TCP -> %s", net.JoinHostPort(s.RemoteAddress.String(), fmt.Sprint(s.RemotePort)), net.JoinHostPort(s.LocalAddress.String(), fmt.Sprint(s.LocalPort)))

// Add address to stack.
addr, _ := netip.AddrFromSlice(net.IP(s.LocalAddress))
addr, _ := netip.AddrFromSlice(s.LocalAddress.AsSlice())
err := transport.GetConnCounts().AddAddress(addr, c.Tnet.Stack(), c.StackLock)
if err != nil {
log.Println("failed to add address:", err)
Expand Down
4 changes: 2 additions & 2 deletions src/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *ConnCounts) AddAddress(addr netip.Addr, s *stack.Stack, stackLock *sync
}
protoAddr := tcpip.ProtocolAddress{
Protocol: protoNumber,
AddressWithPrefix: tcpip.Address(addr.AsSlice()).WithPrefix(),
AddressWithPrefix: tcpip.AddrFromSlice(addr.AsSlice()).WithPrefix(),
}

stackLock.Lock()
Expand Down Expand Up @@ -106,7 +106,7 @@ func (c *ConnCounts) RemoveAddress(addr netip.Addr, s *stack.Stack, stackLock *s
delete(c.counts, addr)

stackLock.Lock()
err := s.RemoveAddress(1, tcpip.Address(addr.AsSlice()))
err := s.RemoveAddress(1, tcpip.AddrFromSlice(addr.AsSlice()))
stackLock.Unlock()

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions src/transport/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
netipv6 "golang.org/x/net/ipv6"

"golang.zx2c4.com/wireguard/tun/netstack"
"gvisor.dev/gvisor/pkg/bufferv2"
"gvisor.dev/gvisor/pkg/buffer"
"gvisor.dev/gvisor/pkg/tcpip"
"gvisor.dev/gvisor/pkg/tcpip/header"
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
Expand Down Expand Up @@ -257,7 +257,7 @@ func handleConn(conn udpConn, port int, s *stack.Stack) {
pktChan, ok := connMapLookup(conn)
if ok {
nilPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
Payload: bufferv2.MakeWithData([]byte{}),
Payload: buffer.MakeWithData([]byte{}),
})
nilPkt.DecRef()
pktChan <- nilPkt
Expand Down Expand Up @@ -341,7 +341,7 @@ func sendResponse(conn udpConn, data []byte, s *stack.Stack) {
return
}

tcpipErr := transport.SendPacket(s, buf.Bytes(), &tcpip.FullAddress{NIC: 1, Addr: tcpip.Address(conn.Source.Addr().AsSlice())}, proto)
tcpipErr := transport.SendPacket(s, buf.Bytes(), &tcpip.FullAddress{NIC: 1, Addr: tcpip.AddrFromSlice(conn.Source.Addr().AsSlice())}, proto)
if tcpipErr != nil {
log.Println("failed to write:", tcpipErr)
return
Expand All @@ -362,7 +362,7 @@ func sendUnreachable(packet stack.PacketBufferPtr, s *stack.Stack) {
transHeader.SetChecksum(0)
transHeaderPayload := transHeader.Payload()

isIpv6 := netHeader.DestinationAddress().To4() == ""
isIpv6 := netHeader.DestinationAddress().To4() == tcpip.Address{}

if isIpv6 {
ipv6Layer = &layers.IPv6{}
Expand Down
2 changes: 1 addition & 1 deletion src/transport/userspace/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func listenNet(tnet *netstack.Net, network string, port int) (*gonet.UDPConn, in
}

addr := netip.AddrPortFrom(ip, uint16(port))
conn, err := gonet.DialUDP(tnet.Stack(), &tcpip.FullAddress{NIC: 1, Addr: tcpip.Address([]byte{}), Port: addr.Port()}, nil, pn)
conn, err := gonet.DialUDP(tnet.Stack(), &tcpip.FullAddress{NIC: 1, Addr: tcpip.AddrFromSlice([]byte{}), Port: addr.Port()}, nil, pn)
if err != nil {
return nil, 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion wiretap.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20
FROM golang:1.21

ARG http_proxy
ARG https_proxy
Expand Down

0 comments on commit c6736ec

Please sign in to comment.