|
|
@@ -3,7 +3,6 @@ package wireguard
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
- "net"
|
|
|
"net/netip"
|
|
|
"runtime"
|
|
|
"strconv"
|
|
|
@@ -13,7 +12,7 @@ import (
|
|
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
|
"github.com/xtls/xray-core/common/log"
|
|
|
- xnet "github.com/xtls/xray-core/common/net"
|
|
|
+ "github.com/xtls/xray-core/common/net"
|
|
|
"github.com/xtls/xray-core/proxy/wireguard/gvisortun"
|
|
|
"gvisor.dev/gvisor/pkg/tcpip"
|
|
|
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
|
|
|
@@ -28,7 +27,7 @@ import (
|
|
|
|
|
|
type tunCreator func(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (Tunnel, error)
|
|
|
|
|
|
-type promiscuousModeHandler func(dest xnet.Destination, conn net.Conn)
|
|
|
+type promiscuousModeHandler func(dest net.Destination, conn net.Conn)
|
|
|
|
|
|
type Tunnel interface {
|
|
|
BuildDevice(ipc string, bind conn.Bind) error
|
|
|
@@ -169,7 +168,7 @@ func createGVisorTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo
|
|
|
ep.SocketOptions().SetKeepAlive(true)
|
|
|
|
|
|
// local address is actually destination
|
|
|
- handler(xnet.TCPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewTCPConn(&wq, ep))
|
|
|
+ handler(net.TCPDestination(net.IPAddress(id.LocalAddress.AsSlice()), net.Port(id.LocalPort)), gonet.NewTCPConn(&wq, ep))
|
|
|
}(r)
|
|
|
})
|
|
|
stack.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket)
|
|
|
@@ -194,7 +193,7 @@ func createGVisorTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo
|
|
|
Timeout: 15 * time.Second,
|
|
|
})
|
|
|
|
|
|
- handler(xnet.UDPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewUDPConn(&wq, ep))
|
|
|
+ handler(net.UDPDestination(net.IPAddress(id.LocalAddress.AsSlice()), net.Port(id.LocalPort)), gonet.NewUDPConn(&wq, ep))
|
|
|
}(r)
|
|
|
})
|
|
|
stack.SetTransportProtocolHandler(udp.ProtocolNumber, udpForwarder.HandlePacket)
|