feat: Use direct dns for direct domain rule-sets and fix rule preview

This commit is contained in:
unknown 2024-07-05 11:02:28 +03:30
parent e40acc3912
commit 8a41dd31ae
No known key found for this signature in database
GPG Key ID: C2CA486E4F771093
7 changed files with 91 additions and 74 deletions

View File

@ -580,6 +580,17 @@ namespace NekoGui {
};
}
// Direct domains in rules
QJsonArray directDnsRuleSets;
auto sets = routeChain->get_direct_site_rule_sets();
for (const auto &item: sets) {
directDnsRuleSets << item;
}
dnsRules += QJsonObject{
{"rule_set", directDnsRuleSets},
{"server", "dns-direct"},
};
// Underlying 100% Working DNS
dnsServers += QJsonObject{
{"tag", "dns-local"},

View File

@ -473,6 +473,18 @@ namespace NekoGui {
return res;
}
QStringList RoutingChain::get_direct_site_rule_sets() {
auto res = QStringList();
for (const auto& item: Rules) {
if (item->outboundID == -2) {
for (const auto& rset: item->rule_set) {
if (rset.endsWith("_SITE")) res << rset;
}
}
}
return res;
}
RoutingChain::RoutingChain(const RoutingChain& other) : JsonStore(other) {
id = other.id;
name = QString(other.name);

View File

@ -76,5 +76,7 @@ namespace NekoGui {
std::shared_ptr<QList<int>> get_used_outbounds();
std::shared_ptr<QStringList> get_used_rule_sets();
QStringList get_direct_site_rule_sets();
};
} // namespace NekoGui

View File

@ -295,16 +295,11 @@ namespace NekoGui {
_add(new configItem("core_box_clash_listen_addr", &core_box_clash_listen_addr, itemType::string));
_add(new configItem("core_box_clash_api_secret", &core_box_clash_api_secret, itemType::string));
_add(new configItem("core_box_underlying_dns", &core_box_underlying_dns, itemType::string));
_add(new configItem("core_ray_direct_dns", &core_ray_direct_dns, itemType::boolean));
_add(new configItem("core_ray_freedom_domainStrategy", &core_ray_freedom_domainStrategy, itemType::string));
_add(new configItem("enable_gso", &enable_gso, itemType::boolean));
_add(new configItem("enable_ntp", &enable_ntp, itemType::boolean));
_add(new configItem("ntp_server_address", &ntp_server_address, itemType::string));
_add(new configItem("ntp_server_port", &ntp_server_port, itemType::integer));
_add(new configItem("ntp_interval", &ntp_interval, itemType::string));
#ifdef Q_OS_WIN
_add(new configItem("core_ray_windows_disable_auto_interface", &core_ray_windows_disable_auto_interface, itemType::boolean));
#endif
}
void DataStore::UpdateStartedId(int id) {

View File

@ -160,9 +160,6 @@ namespace NekoGui {
QString core_box_clash_listen_addr = "127.0.0.1";
QString core_box_clash_api_secret = "";
QString core_box_underlying_dns = "";
bool core_ray_direct_dns = false;
bool core_ray_windows_disable_auto_interface = false;
QString core_ray_freedom_domainStrategy = "";
// Other Core
ExtraCore *extraCore = new ExtraCore;

View File

@ -27,6 +27,63 @@
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<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="3" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>outbound.domain_strategy
when set, domain destinations are resolved to IP before connect,
also if the connection cannot be established with the current address family (ipv4, ipv6), a fallback connection is created shortly after, with the other address family.</string>
</property>
<property name="text">
<string>Outbound Domain Strategy</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="route_prof"/>
</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="1" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Sniffs the connections intial packet(s?) to identify the protocol and the SNI. Sniff result for destination also rewrites the destionation of the connection to the sniffed SNI. For more data on the sniffed protocol refer to the sing-box's documentation.</string>
</property>
<property name="text">
<string>Sniffing Mode</string>
</property>
</widget>
</item>
<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="1">
<widget class="QComboBox" name="sniffing_mode">
<item>
@ -46,28 +103,6 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Sniffs the connections intial packet(s?) to identify the protocol and the SNI. Sniff result for destination also rewrites the destionation of the connection to the sniffed SNI. For more data on the sniffed protocol refer to the sing-box's documentation.</string>
</property>
<property name="text">
<string>Sniffing Mode</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>outbound.domain_strategy
when set, domain destinations are resolved to IP before connect,
also if the connection cannot be established with the current address family (ipv4, ipv6), a fallback connection is created shortly after, with the other address family.</string>
</property>
<property name="text">
<string>Outbound Domain Strategy</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="domainStrategyCombo">
<property name="editable">
@ -75,48 +110,6 @@ also if the connection cannot be established with the current address family (ip
</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="4" column="1">
<widget class="QComboBox" name="route_prof"/>
</item>
<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="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="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">
@ -127,6 +120,13 @@ when used, domain destinations are resolved to IP before routing.</string>
</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>
</layout>
</widget>
</item>
@ -442,7 +442,7 @@ For more information, see the document &quot;Configuration/DNS&quot;.</string>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -118,7 +118,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptr<NekoGui::RoutingChai
ui->rule_attr_text->hide();
ui->rule_attr_data->setTitle("");
ui->rule_attr_box->setEnabled(false);
ui->rule_preview->setEnabled(false);
ui->rule_preview->setReadOnly(true);
updateRuleSection();
connect(ui->route_import_json, &QPushButton::clicked, this, [=] {