mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
add dns intercept and route for tproxy
This commit is contained in:
parent
7262983e02
commit
518f672bbe
@ -84,18 +84,19 @@ namespace Qv2ray::base::config
|
|||||||
bool tproxy_followRedirect;
|
bool tproxy_followRedirect;
|
||||||
/*redirect or tproxy way, and tproxy need cap_net_admin*/
|
/*redirect or tproxy way, and tproxy need cap_net_admin*/
|
||||||
QString tproxy_mode;
|
QString tproxy_mode;
|
||||||
|
bool dnsIntercept;
|
||||||
|
|
||||||
Qv2rayInboundsConfig()
|
Qv2rayInboundsConfig()
|
||||||
: listenip("127.0.0.1"), setSystemProxy(true), useSocks(true), socks_port(1088), socks_useAuth(false), socksUDP(true),
|
: listenip("127.0.0.1"), setSystemProxy(true), useSocks(true), socks_port(1088), socks_useAuth(false), socksUDP(true),
|
||||||
socksLocalIP("127.0.0.1"), socksAccount(), useHTTP(true), http_port(8888), http_useAuth(false), httpAccount(), useTPROXY(false),
|
socksLocalIP("127.0.0.1"), socksAccount(), useHTTP(true), http_port(8888), http_useAuth(false), httpAccount(), useTPROXY(false),
|
||||||
tproxy_ip("127.0.0.1"), tproxy_port(12345), tproxy_use_tcp(true), tproxy_use_udp(false), tproxy_followRedirect(true),
|
tproxy_ip("127.0.0.1"), tproxy_port(12345), tproxy_use_tcp(true), tproxy_use_udp(false), tproxy_followRedirect(true),
|
||||||
tproxy_mode("tproxy")
|
tproxy_mode("tproxy"),dnsIntercept(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
XTOSTRUCT(O(setSystemProxy, listenip, useSocks, useHTTP, socks_port, socks_useAuth, socksAccount, socksUDP, socksLocalIP, http_port,
|
XTOSTRUCT(O(setSystemProxy, listenip, useSocks, useHTTP, socks_port, socks_useAuth, socksAccount, socksUDP, socksLocalIP, http_port,
|
||||||
http_useAuth, httpAccount, useTPROXY, tproxy_ip, tproxy_port, tproxy_use_tcp, tproxy_use_udp, tproxy_followRedirect,
|
http_useAuth, httpAccount, useTPROXY, tproxy_ip, tproxy_port, tproxy_use_tcp, tproxy_use_udp, tproxy_followRedirect,
|
||||||
tproxy_mode))
|
tproxy_mode,dnsIntercept))
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Qv2rayOutboundsConfig
|
struct Qv2rayOutboundsConfig
|
||||||
|
@ -515,6 +515,9 @@ namespace Qv2ray::core::connection
|
|||||||
{
|
{
|
||||||
OutboundMarkSettingFilter(GlobalConfig.outboundConfig.mark, root);
|
OutboundMarkSettingFilter(GlobalConfig.outboundConfig.mark, root);
|
||||||
}
|
}
|
||||||
|
if (GlobalConfig.inboundConfig.useTPROXY && GlobalConfig.inboundConfig.dnsIntercept){
|
||||||
|
DNSInterceptFilter(root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's process some api features.
|
// Let's process some api features.
|
||||||
@ -599,5 +602,22 @@ namespace Qv2ray::core::connection
|
|||||||
root["outbounds"] = outbounds;
|
root["outbounds"] = outbounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DNSInterceptFilter(CONFIGROOT &root){
|
||||||
|
// dns outBound
|
||||||
|
QJsonObject dnsOutboundObj{{"protocol","dns"},{"tag","dns-out"}};
|
||||||
|
OUTBOUNDS outbounds(root["outbounds"].toArray());
|
||||||
|
outbounds.append(dnsOutboundObj);
|
||||||
|
root["outbounds"] = outbounds;
|
||||||
|
|
||||||
|
//dns route
|
||||||
|
QJsonObject dnsRoutingRuleObj{{"outboundTag", "dns-out"},{"port","53"},{"type", "field"}};
|
||||||
|
ROUTING routing(root["routing"].toObject());
|
||||||
|
QJsonArray _rules(routing["rules"].toArray());
|
||||||
|
_rules.insert(0,dnsRoutingRuleObj);
|
||||||
|
routing["rules"]=_rules;
|
||||||
|
root["routing"]=routing;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Generation
|
} // namespace Generation
|
||||||
} // namespace Qv2ray::core::connection
|
} // namespace Qv2ray::core::connection
|
||||||
|
@ -40,6 +40,8 @@ namespace Qv2ray::core::connection
|
|||||||
// mark all outbound
|
// mark all outbound
|
||||||
void OutboundMarkSettingFilter(const int mark, CONFIGROOT &root);
|
void OutboundMarkSettingFilter(const int mark, CONFIGROOT &root);
|
||||||
|
|
||||||
|
void DNSInterceptFilter(CONFIGROOT &root);
|
||||||
|
|
||||||
} // namespace Generation
|
} // namespace Generation
|
||||||
} // namespace Qv2ray::core::connection
|
} // namespace Qv2ray::core::connection
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), Current
|
|||||||
tproxyFollowRedirect->setChecked(CurrentConfig.inboundConfig.tproxy_followRedirect);
|
tproxyFollowRedirect->setChecked(CurrentConfig.inboundConfig.tproxy_followRedirect);
|
||||||
tproxyMode->setCurrentText(CurrentConfig.inboundConfig.tproxy_mode);
|
tproxyMode->setCurrentText(CurrentConfig.inboundConfig.tproxy_mode);
|
||||||
outboundMark->setValue(CurrentConfig.outboundConfig.mark);
|
outboundMark->setValue(CurrentConfig.outboundConfig.mark);
|
||||||
|
dnsIntercept->setChecked(CurrentConfig.inboundConfig.dnsIntercept);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
vCorePathTxt->setText(CurrentConfig.kernelConfig.KernelPath());
|
vCorePathTxt->setText(CurrentConfig.kernelConfig.KernelPath());
|
||||||
@ -1262,3 +1263,11 @@ void PreferencesWindow::on_outboundMark_valueChanged(int arg1)
|
|||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.outboundConfig.mark=arg1;
|
CurrentConfig.outboundConfig.mark=arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PreferencesWindow::on_dnsIntercept_toggled(bool checked)
|
||||||
|
{
|
||||||
|
NEEDRESTART
|
||||||
|
CurrentConfig.inboundConfig.dnsIntercept=checked;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -196,6 +196,8 @@ class PreferencesWindow
|
|||||||
|
|
||||||
void on_outboundMark_valueChanged(int arg1);
|
void on_outboundMark_valueChanged(int arg1);
|
||||||
|
|
||||||
|
void on_dnsIntercept_toggled(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
RouteSettingsMatrixWidget *routeSettingsWidget;
|
RouteSettingsMatrixWidget *routeSettingsWidget;
|
||||||
|
@ -705,8 +705,8 @@ Custom DNS Settings</string>
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>710</width>
|
<width>703</width>
|
||||||
<height>520</height>
|
<height>524</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
@ -1013,6 +1013,13 @@ Custom DNS Settings</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="dnsIntercept">
|
||||||
|
<property name="text">
|
||||||
|
<string>DNS Intercept</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
Reference in New Issue
Block a user