fix: ipv4in6 should be converged

This commit is contained in:
mzz2017
2023-02-13 18:26:31 +08:00
parent 79423f7ff1
commit 2a586e6341
3 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"net/netip"
"net/url"
"path/filepath"
"reflect"
@ -366,3 +367,10 @@ func BoolToString(b bool) string {
return "0"
}
}
func ConvergeIp(addr netip.Addr) netip.Addr {
if addr.Is4In6() {
addr = netip.AddrFrom4(addr.As4())
}
return addr
}

View File

@ -11,6 +11,7 @@ import (
"fmt"
"github.com/mzz2017/softwind/pool"
"github.com/sirupsen/logrus"
"github.com/v2rayA/dae/common"
"github.com/v2rayA/dae/common/consts"
"github.com/v2rayA/dae/component/outbound/dialer"
"golang.org/x/net/dns/dnsmessage"
@ -287,7 +288,7 @@ func (c *ControlPlane) handlePkt(lConn *net.UDPConn, data []byte, src, pktDst, r
// We only validate rush-ans when outbound is direct and pkt does not send to a home device.
// Because additional record OPT may not be supported by home router.
// So se should trust home devices even if they make rush-answer (or looks like).
return outboundIndex == consts.OutboundDirect && !from.Addr().IsPrivate()
return outboundIndex == consts.OutboundDirect && !common.ConvergeIp(from.Addr()).IsPrivate()
})
// Dial and send.

View File

@ -8,8 +8,8 @@ global {
# Node connectivity check.
# Host of URL should have both IPv4 and IPv6 if you have double stack in local.
# Considering traffic consumption, it is recommended to choose a site with less response.
tcp_check_url: 'http://captive.apple.com'
# Considering traffic consumption, it is recommended to choose a site with anycast IP and less response.
tcp_check_url: 'http://detectportal.firefox.com/success.txt'
# This DNS will be used to check UDP connectivity of nodes. And if dns_upstream below contains tcp, it also be used to check
# TCP DNS connectivity of nodes.