Skip to content

Commit

Permalink
mark all dns request for xray/v2ray/sing-box
Browse files Browse the repository at this point in the history
  • Loading branch information
whalechoi committed Jul 19, 2023
1 parent c30df90 commit 286418a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main/proxies/tproxy/tproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func createProxyChain(ipv6 bool) error {
}
}
}
// mark all dns request
if builds.Config.XrayHelper.CoreType != "clash" && builds.Config.XrayHelper.CoreType != "clash.meta" {
if err := currentIpt.Insert("mangle", "PROXY", 1, "-p", "udp", "-m", "owner", "!", "--gid-owner", common.CoreGid, "--dport", "53", "-j", "MARK", "--set-mark", common.TproxyMarkId); err != nil {
return errors.New("mark all dns request on "+currentProto+" udp mangle chain PROXY failed, ", err).WithPrefix("tproxy")
}
}
// apply rules to OUTPUT
if err := currentIpt.Append("mangle", "OUTPUT", "-j", "PROXY"); err != nil {
return errors.New("apply mangle chain PROXY to OUTPUT failed, ", err).WithPrefix("tproxy")
Expand Down
6 changes: 6 additions & 0 deletions main/proxies/tun/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ func createProxyChain(ipv6 bool) error {
}
}
}
// mark all dns request
if builds.Config.XrayHelper.CoreType != "clash" && builds.Config.XrayHelper.CoreType != "clash.meta" {
if err := currentIpt.Insert("mangle", "XT", 1, "-p", "udp", "-m", "owner", "!", "--gid-owner", common.CoreGid, "--dport", "53", "-j", "TUN2SOCKS"); err != nil {
return errors.New("mark all dns request on "+currentProto+" udp mangle chain XT failed, ", err).WithPrefix("tproxy")
}
}
// apply rules to OUTPUT
if err := currentIpt.Append("mangle", "OUTPUT", "-j", "XT"); err != nil {
return errors.New("apply mangle chain XT to OUTPUT failed, ", err).WithPrefix("tun")
Expand Down

0 comments on commit 286418a

Please sign in to comment.