make Tun routing optional

This commit is contained in:
Nova 2025-04-23 05:20:00 +03:30
parent dea6514caf
commit 52ca4dbfbe
5 changed files with 15 additions and 1 deletions

View File

@ -113,6 +113,7 @@ namespace NekoGui {
// VPN // VPN
bool fake_dns = false; bool fake_dns = false;
bool enable_tun_routing = false;
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
QString vpn_implementation = "gvisor"; QString vpn_implementation = "gvisor";
#else #else

View File

@ -93,6 +93,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="tun_routing">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When enabled, Direct IP CIDRs and rule sets will also be added to the Tun setting to be excluded at OS routing level. IMPORTANT: Large rule sets have been reported to cause massive CPU usage in windows, please enable this option with caution.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Tun Routing</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -504,7 +504,7 @@ namespace NekoGui {
if (dataStore->vpn_ipv6) tunAddress += "fdfe:dcba:9876::1/96"; if (dataStore->vpn_ipv6) tunAddress += "fdfe:dcba:9876::1/96";
inboundObj["address"] = tunAddress; inboundObj["address"] = tunAddress;
inboundObj["domain_strategy"] = dataStore->routing->domain_strategy; inboundObj["domain_strategy"] = dataStore->routing->domain_strategy;
if (dataStore->routing->def_outbound == "proxy") if (dataStore->enable_tun_routing && dataStore->routing->def_outbound == "proxy")
{ {
if (!directIPCIDRs.isEmpty()) inboundObj["route_exclude_address"] = directIPCIDRs; if (!directIPCIDRs.isEmpty()) inboundObj["route_exclude_address"] = directIPCIDRs;
if (!directIPSets.isEmpty()) inboundObj["route_exclude_address_set"] = directIPSets; if (!directIPSets.isEmpty()) inboundObj["route_exclude_address_set"] = directIPSets;

View File

@ -308,6 +308,7 @@ namespace NekoGui {
_add(new configItem("stats_tab", &stats_tab, itemType::string)); _add(new configItem("stats_tab", &stats_tab, itemType::string));
_add(new configItem("proxy_scheme", &proxy_scheme, itemType::string)); _add(new configItem("proxy_scheme", &proxy_scheme, itemType::string));
_add(new configItem("disable_privilege_req", &disable_privilege_req, itemType::boolean)); _add(new configItem("disable_privilege_req", &disable_privilege_req, itemType::boolean));
_add(new configItem("enable_tun_routing", &enable_tun_routing, itemType::boolean));
} }
void DataStore::UpdateStartedId(int id) { void DataStore::UpdateStartedId(int id) {

View File

@ -16,6 +16,7 @@ DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new
ui->vpn_mtu->setCurrentText(Int2String(NekoGui::dataStore->vpn_mtu)); ui->vpn_mtu->setCurrentText(Int2String(NekoGui::dataStore->vpn_mtu));
ui->vpn_ipv6->setChecked(NekoGui::dataStore->vpn_ipv6); ui->vpn_ipv6->setChecked(NekoGui::dataStore->vpn_ipv6);
ui->strict_route->setChecked(NekoGui::dataStore->vpn_strict_route); ui->strict_route->setChecked(NekoGui::dataStore->vpn_strict_route);
ui->tun_routing->setChecked(NekoGui::dataStore->enable_tun_routing);
ADJUST_SIZE ADJUST_SIZE
} }
@ -31,6 +32,7 @@ void DialogVPNSettings::accept() {
NekoGui::dataStore->vpn_mtu = mtu; NekoGui::dataStore->vpn_mtu = mtu;
NekoGui::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked(); NekoGui::dataStore->vpn_ipv6 = ui->vpn_ipv6->isChecked();
NekoGui::dataStore->vpn_strict_route = ui->strict_route->isChecked(); NekoGui::dataStore->vpn_strict_route = ui->strict_route->isChecked();
NekoGui::dataStore->enable_tun_routing = ui->tun_routing->isChecked();
// //
QStringList msg{"UpdateDataStore"}; QStringList msg{"UpdateDataStore"};
msg << "VPNChanged"; msg << "VPNChanged";