Merge remote-tracking branch 'tun/with-tun' into Alpha
This commit is contained in:
commit
24583009c4
3 changed files with 6 additions and 12 deletions
|
@ -27,15 +27,9 @@ func RelayDnsPacket(payload []byte) ([]byte, error) {
|
|||
|
||||
r, err := resolver.ServeMsg(msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, ans := range r.Answer {
|
||||
header := ans.Header()
|
||||
|
||||
if header.Class == D.ClassINET && (header.Rrtype == D.TypeA || header.Rrtype == D.TypeAAAA) {
|
||||
header.Ttl = 1
|
||||
}
|
||||
m := new(D.Msg)
|
||||
m.SetRcode(msg, D.RcodeServerFailure)
|
||||
return m.Pack()
|
||||
}
|
||||
|
||||
r.SetRcode(msg, r.Rcode)
|
||||
|
|
|
@ -74,8 +74,8 @@ func (u *UDP) WriteTo(buf []byte, local net.Addr, remote net.Addr) (int, error)
|
|||
srcIP, _ := netip.AddrFromSlice(srcAddr.IP)
|
||||
dstIp, _ := netip.AddrFromSlice(dstAddr.IP)
|
||||
|
||||
srcAddrPort := netip.AddrPortFrom(srcIP, uint16(srcAddr.Port))
|
||||
dstAddrPort := netip.AddrPortFrom(dstIp, uint16(dstAddr.Port))
|
||||
srcAddrPort := netip.AddrPortFrom(srcIP.Unmap(), uint16(srcAddr.Port))
|
||||
dstAddrPort := netip.AddrPortFrom(dstIp.Unmap(), uint16(dstAddr.Port))
|
||||
|
||||
if !srcAddrPort.Addr().Is4() || !dstAddrPort.Addr().Is4() {
|
||||
return 0, net.InvalidAddrError("invalid ip version")
|
||||
|
|
|
@ -176,7 +176,7 @@ func New(device device.Device, dnsHijack []netip.AddrPort, tunAddress netip.Pref
|
|||
local: lAddr,
|
||||
data: raw,
|
||||
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() {
|
||||
pool.Put(buf)
|
||||
|
|
Loading…
Reference in a new issue