pufferffish / wireproxy

Wireguard client that exposes itself as a socks5 proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error compiling build constraints error in gvisor

lockevod opened this issue · comments

Hello I'm triying to compile (Macos Ventura M2 chip)

I have this error

imports gvisor.dev/gvisor/pkg/gohacks: build constraints exclude all Go files in /Users/sergi/go/pkg/mod/gvisor.dev/gvisor@v0.0.0-20221203005347-703fd9b7fbc0/pkg/gohacks

Thanks

Same issue here

Same here, building for Linux x86

I just built this from Git master on both Windows x64 and Android ARM64 (Go 1.21.1 and 1.21.0 via Termux respectively). Quick instructions:

  1. Clone this repository somewhere
  2. In the wireproxy folder, git clone https://git.zx2c4.com/wireguard-go
  3. Apply this patch to wireguard-go:
diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 596cfcd..bff5d15 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -25,7 +25,7 @@ import (
 	"golang.zx2c4.com/wireguard/tun"
 
 	"golang.org/x/net/dns/dnsmessage"
-	"gvisor.dev/gvisor/pkg/bufferv2"
+	"gvisor.dev/gvisor/pkg/buffer"
 	"gvisor.dev/gvisor/pkg/tcpip"
 	"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
 	"gvisor.dev/gvisor/pkg/tcpip/header"
@@ -43,7 +43,7 @@ type netTun struct {
 	ep             *channel.Endpoint
 	stack          *stack.Stack
 	events         chan tun.Event
-	incomingPacket chan *bufferv2.View
+	incomingPacket chan *buffer.View
 	mtu            int
 	dnsServers     []netip.Addr
 	hasV4, hasV6   bool
@@ -61,7 +61,7 @@ func CreateNetTUN(localAddresses, dnsServers []netip.Addr, mtu int) (tun.Device,
 		ep:             channel.New(1024, uint32(mtu), ""),
 		stack:          stack.New(opts),
 		events:         make(chan tun.Event, 10),
-		incomingPacket: make(chan *bufferv2.View),
+		incomingPacket: make(chan *buffer.View),
 		dnsServers:     dnsServers,
 		mtu:            mtu,
 	}
@@ -84,7 +84,7 @@ func CreateNetTUN(localAddresses, dnsServers []netip.Addr, mtu int) (tun.Device,
 		}
 		protoAddr := tcpip.ProtocolAddress{
 			Protocol:          protoNumber,
-			AddressWithPrefix: tcpip.Address(ip.AsSlice()).WithPrefix(),
+			AddressWithPrefix: tcpip.AddrFromSlice(ip.AsSlice()).WithPrefix(),
 		}
 		tcpipErr := dev.stack.AddProtocolAddress(1, protoAddr, stack.AddressProperties{})
 		if tcpipErr != nil {
@@ -140,7 +140,7 @@ func (tun *netTun) Write(buf [][]byte, offset int) (int, error) {
 			continue
 		}
 
-		pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: bufferv2.MakeWithData(packet)})
+		pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: buffer.MakeWithData(packet)})
 		switch packet[0] >> 4 {
 		case 4:
 			tun.ep.InjectInbound(header.IPv4ProtocolNumber, pkb)
@@ -198,7 +198,7 @@ func convertToFullAddr(endpoint netip.AddrPort) (tcpip.FullAddress, tcpip.Networ
 	}
 	return tcpip.FullAddress{
 		NIC:  1,
-		Addr: tcpip.Address(endpoint.Addr().AsSlice()),
+		Addr: tcpip.AddrFromSlice(endpoint.Addr().AsSlice()),
 		Port: endpoint.Port(),
 	}, protoNumber
 }
@@ -453,7 +453,7 @@ func (pc *PingConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
 		return 0, nil, fmt.Errorf("ping read: %s", tcpipErr)
 	}
 
-	remoteAddr, _ := netip.AddrFromSlice([]byte(res.RemoteAddr.Addr))
+	remoteAddr, _ := netip.AddrFromSlice([]byte(res.RemoteAddr.Addr.AsSlice()))
 	return res.Count, &PingAddr{remoteAddr}, nil
 }
 
  1. Update all the dependencies in wireproxy's go.mod. I don't know how to do this myself; I opened the repo in VS Code with the Go extension installed and just clicked the upgrade buttons in go.mod as much as I could 🤷‍♂️
  2. In the same go.mod, replace the gvisor.dev/gvisor v0.0.0-20221203005347-703fd9b7fbc0 // indirect (or similar) line with gvisor.dev/gvisor v0.0.0-20230928000133-4fe30062272c // indirect and add this at the bottom of the file:
// https://github.com/google/gvisor/tree/go
replace gvisor.dev/gvisor => github.com/google/gvisor v0.0.0-20230928000133-4fe30062272c
replace golang.zx2c4.com/wireguard => ./wireguard-go
  1. Run go mod tidy or whatever command it is that reconciles go.sum with go.mod
  2. Try building with the Makefile and if I didn't forget anything here, you didn't mess anything up, and the upstream Go libraries remain relatively the same since the posting of this comment, you might also be able to enjoy a fresh wireproxy binary.

Also having this problem. It'd be interesting to see a go.sum left over from someone's working build.