fix rule order for sniff

This commit is contained in:
Nova 2025-02-14 13:18:36 +03:30
parent d3290e0d85
commit 5bf106f25d

View File

@ -365,6 +365,8 @@ namespace NekoGui {
status->result->error = "Routing profile does not exist, try resetting the route profile in Routing Settings"; status->result->error = "Routing profile does not exist, try resetting the route profile in Routing Settings";
return; return;
} }
// copy for modification
routeChain = std::make_shared<RoutingChain>(*routeChain);
// Inbounds // Inbounds
// mixed-in // mixed-in
@ -425,12 +427,13 @@ namespace NekoGui {
auto sniffRule = std::make_shared<RouteRule>(); auto sniffRule = std::make_shared<RouteRule>();
sniffRule->action = "sniff"; sniffRule->action = "sniff";
sniffRule->inbound = {"dns-in"}; sniffRule->inbound = {"dns-in"};
routeChain->Rules += sniffRule;
auto redirRule = std::make_shared<RouteRule>(); auto redirRule = std::make_shared<RouteRule>();
redirRule->action = "hijack-dns"; redirRule->action = "hijack-dns";
redirRule->inbound = {"dns-in"}; redirRule->inbound = {"dns-in"};
routeChain->Rules += redirRule;
routeChain->Rules.prepend(redirRule);
routeChain->Rules.prepend(sniffRule);
} }
if (dataStore->enable_redirect && !status->forTest) { if (dataStore->enable_redirect && !status->forTest) {
status->inbounds.prepend(QJsonObject{ status->inbounds.prepend(QJsonObject{
@ -443,7 +446,7 @@ namespace NekoGui {
sniffRule->action = "sniff"; sniffRule->action = "sniff";
sniffRule->sniffOverrideDest = true; sniffRule->sniffOverrideDest = true;
sniffRule->inbound = {"hijack"}; sniffRule->inbound = {"hijack"};
routeChain->Rules += sniffRule; routeChain->Rules.prepend(sniffRule);
} }
// custom inbound // custom inbound
@ -476,7 +479,7 @@ namespace NekoGui {
{ {
sniffRule->sniffOverrideDest = true; sniffRule->sniffOverrideDest = true;
} }
routeChain->Rules += sniffRule; routeChain->Rules.prepend(sniffRule);
} }
auto neededOutbounds = routeChain->get_used_outbounds(); auto neededOutbounds = routeChain->get_used_outbounds();
auto neededRuleSets = routeChain->get_used_rule_sets(); auto neededRuleSets = routeChain->get_used_rule_sets();