Fix gateway & FIx prefix check

This commit is contained in:
世界 2024-10-26 14:54:08 +08:00
parent 07278fb470
commit 10f73346a0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 111 additions and 45 deletions

View file

@ -573,11 +573,18 @@ func (r *autoRedirect) nftablesCreateDNSHijackRulesForFamily(
})
if !dnsServer.IsValid() {
if family == nftables.TableFamilyIPv4 {
dnsServer = r.tunOptions.Inet4Address[0].Addr().Next()
if HasNextAddress(r.tunOptions.Inet4Address[0], 1) {
dnsServer = r.tunOptions.Inet4Address[0].Addr().Next()
}
} else {
dnsServer = r.tunOptions.Inet6Address[0].Addr().Next()
if HasNextAddress(r.tunOptions.Inet6Address[0], 1) {
dnsServer = r.tunOptions.Inet6Address[0].Addr().Next()
}
}
}
if !dnsServer.IsValid() {
return nil
}
exprs := []expr.Any{
&expr.Meta{
Key: expr.MetaKeyNFPROTO,