Fix: udp 4In6 of tun system stack
This commit is contained in:
parent
ef915c94dc
commit
c6efa74a6b
2 changed files with 3 additions and 3 deletions
|
@ -74,8 +74,8 @@ func (u *UDP) WriteTo(buf []byte, local net.Addr, remote net.Addr) (int, error)
|
||||||
srcIP, _ := netip.AddrFromSlice(srcAddr.IP)
|
srcIP, _ := netip.AddrFromSlice(srcAddr.IP)
|
||||||
dstIp, _ := netip.AddrFromSlice(dstAddr.IP)
|
dstIp, _ := netip.AddrFromSlice(dstAddr.IP)
|
||||||
|
|
||||||
srcAddrPort := netip.AddrPortFrom(srcIP, uint16(srcAddr.Port))
|
srcAddrPort := netip.AddrPortFrom(srcIP.Unmap(), uint16(srcAddr.Port))
|
||||||
dstAddrPort := netip.AddrPortFrom(dstIp, uint16(dstAddr.Port))
|
dstAddrPort := netip.AddrPortFrom(dstIp.Unmap(), uint16(dstAddr.Port))
|
||||||
|
|
||||||
if !srcAddrPort.Addr().Is4() || !dstAddrPort.Addr().Is4() {
|
if !srcAddrPort.Addr().Is4() || !dstAddrPort.Addr().Is4() {
|
||||||
return 0, net.InvalidAddrError("invalid ip version")
|
return 0, net.InvalidAddrError("invalid ip version")
|
||||||
|
|
|
@ -176,7 +176,7 @@ func New(device device.Device, dnsHijack []netip.AddrPort, tunAddress netip.Pref
|
||||||
local: lAddr,
|
local: lAddr,
|
||||||
data: raw,
|
data: raw,
|
||||||
writeBack: func(b []byte, addr net.Addr) (int, error) {
|
writeBack: func(b []byte, addr net.Addr) (int, error) {
|
||||||
return stack.UDP().WriteTo(b, addr, lAddr)
|
return stack.UDP().WriteTo(b, rAddr, lAddr)
|
||||||
},
|
},
|
||||||
drop: func() {
|
drop: func() {
|
||||||
pool.Put(buf)
|
pool.Put(buf)
|
||||||
|
|
Loading…
Reference in a new issue