mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
move default outbound to routing profile
This commit is contained in:
parent
e6bf936c8e
commit
61af47367f
@ -5,6 +5,23 @@
|
||||
#include "include/global/NekoGui.hpp"
|
||||
|
||||
namespace NekoGui {
|
||||
enum outboundID {proxyID=-1, directID=-2, blockID=-3, dnsOutID=-4};
|
||||
inline QString outboundIDToString(int id)
|
||||
{
|
||||
if (id == proxyID) return {"proxy"};
|
||||
if (id == directID) return {"direct"};
|
||||
if (id == blockID) return {"block"};
|
||||
if (id == dnsOutID) return {"dns"};
|
||||
return {"unknown"};
|
||||
}
|
||||
inline outboundID stringToOutboundID(const QString& out)
|
||||
{
|
||||
if (out == "proxy") return proxyID;
|
||||
if (out == "direct") return directID;
|
||||
if (out == "block") return blockID;
|
||||
if (out == "dns_out") return dnsOutID;
|
||||
return proxyID;
|
||||
}
|
||||
enum inputType {trufalse, select, text};
|
||||
const int IranBypassChainID = 111111111;
|
||||
const int ChinaBypassChainID = 222222222;
|
||||
@ -57,7 +74,7 @@ namespace NekoGui {
|
||||
QList<QString> process_path_regex;
|
||||
QList<QString> rule_set;
|
||||
bool invert = false;
|
||||
int outboundID = -2; // -1 is proxy -2 is direct -3 is block -4 is dns_out
|
||||
int outboundID = directID; // -1 is proxy -2 is direct -3 is block -4 is dns_out
|
||||
// since sing-box 1.11.0
|
||||
QString action = "route";
|
||||
|
||||
@ -94,6 +111,7 @@ namespace NekoGui {
|
||||
QString name = "";
|
||||
QList<std::shared_ptr<RouteRule>> Rules;
|
||||
QList<JsonStore*> castedRules;
|
||||
int defaultOutboundID = proxyID;
|
||||
|
||||
RoutingChain();
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ namespace NekoGui {
|
||||
class Routing : public JsonStore {
|
||||
public:
|
||||
int current_route_id = 0;
|
||||
QString def_outbound = "proxy";
|
||||
|
||||
// DNS
|
||||
QString remote_dns = "tls://8.8.8.8";
|
||||
|
||||
@ -34,6 +34,20 @@
|
||||
<item>
|
||||
<widget class="QGroupBox" name="simple_direct_box">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QComboBox" name="def_out">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>proxy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>direct</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
||||
@ -27,61 +27,8 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="outbound_domain_strategy">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="domainStrategyCombo">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="route_prof_l">
|
||||
<property name="text">
|
||||
<string>Routing Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="default_out">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">proxy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">direct</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="default_out_l">
|
||||
<property name="toolTip">
|
||||
<string>The outbound tag to use when the request is not handled by any rule</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default Outbound</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string notr="true">inbound.domain_strategy
|
||||
when used, domain destinations are resolved to IP before routing.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inbound Domain Strategy</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="route_prof"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@ -95,8 +42,12 @@ also if the connection cannot be established with the current address family (ip
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="route_prof"/>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="outbound_domain_strategy">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
@ -108,6 +59,17 @@ also if the connection cannot be established with the current address family (ip
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string notr="true">inbound.domain_strategy
|
||||
when used, domain destinations are resolved to IP before routing.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inbound Domain Strategy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="sniffing_mode">
|
||||
<item>
|
||||
@ -127,6 +89,20 @@ also if the connection cannot be established with the current address family (ip
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="route_prof_l">
|
||||
<property name="text">
|
||||
<string>Routing Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="domainStrategyCombo">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -520,7 +520,7 @@ namespace NekoGui {
|
||||
if (dataStore->vpn_ipv6) tunAddress += "fdfe:dcba:9876::1/96";
|
||||
inboundObj["address"] = tunAddress;
|
||||
inboundObj["domain_strategy"] = dataStore->routing->domain_strategy;
|
||||
if (dataStore->enable_tun_routing && dataStore->routing->def_outbound == "proxy")
|
||||
if (dataStore->enable_tun_routing && routeChain->defaultOutboundID == proxyID)
|
||||
{
|
||||
if (!directIPCIDRs.isEmpty()) inboundObj["route_exclude_address"] = directIPCIDRs;
|
||||
if (!directIPSets.isEmpty()) inboundObj["route_exclude_address_set"] = directIPSets;
|
||||
@ -592,7 +592,7 @@ namespace NekoGui {
|
||||
{
|
||||
routeObj["find_process"] = true;
|
||||
}
|
||||
if (!status->forTest) routeObj["final"] = dataStore->routing->def_outbound;
|
||||
if (!status->forTest) routeObj["final"] = outboundIDToString(routeChain->defaultOutboundID);
|
||||
|
||||
if (dataStore->routing->sniffing_mode != SniffingMode::DISABLE)
|
||||
{
|
||||
|
||||
@ -815,6 +815,7 @@ namespace NekoGui {
|
||||
|
||||
_add(new configItem("id", &id, itemType::integer));
|
||||
_add(new configItem("name", &name, itemType::string));
|
||||
_add(new configItem("default_outbound", &defaultOutboundID, itemType::integer));
|
||||
_add(new configItem("rules", &castedRules, itemType::jsonStoreList));
|
||||
}
|
||||
|
||||
|
||||
@ -334,7 +334,6 @@ namespace NekoGui {
|
||||
if (!Preset::SingBox::DomainStrategy.contains(domain_strategy)) domain_strategy = "";
|
||||
if (!Preset::SingBox::DomainStrategy.contains(outbound_domain_strategy)) outbound_domain_strategy = "";
|
||||
_add(new configItem("current_route_id", &this->current_route_id, itemType::integer));
|
||||
_add(new configItem("default_outbound", &this->def_outbound, itemType::string));
|
||||
//
|
||||
_add(new configItem("remote_dns", &this->remote_dns, itemType::string));
|
||||
_add(new configItem("remote_dns_strategy", &this->remote_dns_strategy, itemType::string));
|
||||
|
||||
@ -121,6 +121,8 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptr<NekoGui::RoutingChai
|
||||
ui->rule_preview->setReadOnly(true);
|
||||
updateRuleSection();
|
||||
|
||||
ui->def_out->setCurrentText(NekoGui::outboundIDToString(chain->defaultOutboundID));
|
||||
|
||||
// simple rules setup
|
||||
QStringList ruleItems = {"domain:", "suffix:", "regex:", "keyword:", "ip:", "processName:", "processPath:"};
|
||||
for (const auto& geoIP : geoIpList) {
|
||||
@ -337,6 +339,7 @@ void RouteItem::accept() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
chain->defaultOutboundID = NekoGui::stringToOutboundID(ui->def_out->currentText());
|
||||
|
||||
emit settingsChanged(chain);
|
||||
|
||||
|
||||
@ -76,7 +76,6 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne
|
||||
QStringList qsValue = {""};
|
||||
QString dnsHelpDocumentUrl;
|
||||
|
||||
ui->default_out->setCurrentText(NekoGui::dataStore->routing->def_outbound);
|
||||
ui->outbound_domain_strategy->addItems(Preset::SingBox::DomainStrategy);
|
||||
ui->domainStrategyCombo->addItems(Preset::SingBox::DomainStrategy);
|
||||
qsValue += QString("prefer_ipv4 prefer_ipv6 ipv4_only ipv6_only").split(" ");
|
||||
@ -209,7 +208,6 @@ void DialogManageRoutes::accept() {
|
||||
|
||||
NekoGui::profileManager->UpdateRouteChains(chainList);
|
||||
NekoGui::dataStore->routing->current_route_id = currentRoute->id;
|
||||
NekoGui::dataStore->routing->def_outbound = ui->default_out->currentText();
|
||||
|
||||
NekoGui::dataStore->enable_dns_server = ui->dnshijack_enable->isChecked();
|
||||
NekoGui::dataStore->dns_server_listen_port = ui->dnshijack_listenport->text().toInt();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user