mirror of
https://github.com/chenx-dust/EZ4Connect.git
synced 2026-09-20 02:13:32 +08:00
feat: 支持更多的 DNS 配置选项
This commit is contained in:
@@ -22,6 +22,8 @@ void DefaultSettings::reset(QSettings &settings)
|
||||
settings.setValue("ZJUConnect/DNS", "");
|
||||
settings.setValue("ZJUConnect/DNSAuto", true);
|
||||
settings.setValue("ZJUConnect/SecondaryDNS", "");
|
||||
settings.setValue("ZJUConnect/LocalDNSServer", "");
|
||||
settings.setValue("ZJUConnect/DNSServerBind", "");
|
||||
settings.setValue("ZJUConnect/DNSTTL", 3600);
|
||||
settings.setValue("ZJUConnect/SOCKS5Port", 11080);
|
||||
settings.setValue("ZJUConnect/HTTPPort", 11081);
|
||||
|
||||
@@ -31,6 +31,8 @@ struct DnsOptions
|
||||
int ttl = 3600;
|
||||
bool disableZjuDns = false;
|
||||
QString custom;
|
||||
QString localDnsServer;
|
||||
QString dnsServerBind;
|
||||
};
|
||||
|
||||
struct ProxyOptions
|
||||
|
||||
@@ -171,13 +171,15 @@ CoreCommand CoreCommandBuilder::build(const ConnectionProfile &profile, const Co
|
||||
|
||||
if (!profile.dns.primary.isEmpty() || profile.dns.automatic)
|
||||
{
|
||||
arguments << "-zju-dns-server" << (profile.dns.automatic ? "auto" : profile.dns.primary);
|
||||
arguments << "-remote-dns-server" << (profile.dns.automatic ? "auto" : profile.dns.primary);
|
||||
}
|
||||
if (profile.dns.ttl != 3600)
|
||||
{
|
||||
arguments << "-dns-ttl" << QString::number(profile.dns.ttl);
|
||||
}
|
||||
appendOption(arguments, "-secondary-dns-server", profile.dns.secondary);
|
||||
appendOption(arguments, "-local-dns-server", profile.dns.localDnsServer);
|
||||
appendOption(arguments, "-dns-server-bind", profile.dns.dnsServerBind);
|
||||
|
||||
if (profile.behavior.disableKeepAlive)
|
||||
{
|
||||
@@ -191,7 +193,7 @@ CoreCommand CoreCommandBuilder::build(const ConnectionProfile &profile, const Co
|
||||
}
|
||||
if (profile.dns.disableZjuDns)
|
||||
{
|
||||
arguments << "-disable-zju-dns";
|
||||
arguments << "-disable-remote-dns";
|
||||
}
|
||||
if (profile.behavior.disableServerConfig)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,9 @@ ConnectionProfile SettingsProfileLoader::load(
|
||||
settings.value("ZJUConnect/SecondaryDNS").toString(),
|
||||
settings.value("ZJUConnect/DNSTTL").toInt(),
|
||||
settings.value("ZJUConnect/DisableZJUDNS").toBool(),
|
||||
settings.value("ZJUConnect/CustomDNS", "").toString()
|
||||
settings.value("ZJUConnect/CustomDNS", "").toString(),
|
||||
settings.value("ZJUConnect/LocalDNSServer", "").toString(),
|
||||
settings.value("ZJUConnect/DNSServerBind", "").toString()
|
||||
};
|
||||
|
||||
const QString bindPrefix = settings.value("ZJUConnect/OutsideAccess", false).toBool()
|
||||
|
||||
@@ -238,6 +238,12 @@ void SettingWindow::loadSettings()
|
||||
ui->dnsLineEdit->setText(settings->value("ZJUConnect/DNS").toString());
|
||||
ui->dnsAutoCheckBox->setChecked(settings->value("ZJUConnect/DNSAuto").toBool());
|
||||
ui->secondaryDnsLineEdit->setText(settings->value("ZJUConnect/SecondaryDNS").toString());
|
||||
ui->localDnsServerLineEdit->setText(
|
||||
settings->value("ZJUConnect/LocalDNSServer", "").toString()
|
||||
);
|
||||
ui->dnsServerBindLineEdit->setText(
|
||||
settings->value("ZJUConnect/DNSServerBind", "").toString()
|
||||
);
|
||||
ui->dnsTTLSpinBox->setValue(settings->value("ZJUConnect/DNSTTL").toInt());
|
||||
ui->socks5PortSpinBox->setValue(settings->value("ZJUConnect/SOCKS5Port").toInt());
|
||||
ui->httpPortSpinBox->setValue(settings->value("ZJUConnect/HTTPPort").toInt());
|
||||
@@ -338,6 +344,14 @@ void SettingWindow::applySettings()
|
||||
settings->setValue("ZJUConnect/DNS", ui->dnsLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DNSAuto", ui->dnsAutoCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/SecondaryDNS", ui->secondaryDnsLineEdit->text());
|
||||
settings->setValue(
|
||||
"ZJUConnect/LocalDNSServer",
|
||||
ui->localDnsServerLineEdit->text().trimmed()
|
||||
);
|
||||
settings->setValue(
|
||||
"ZJUConnect/DNSServerBind",
|
||||
ui->dnsServerBindLineEdit->text().trimmed()
|
||||
);
|
||||
settings->setValue("ZJUConnect/DNSTTL", ui->dnsTTLSpinBox->value());
|
||||
settings->setValue("ZJUConnect/SOCKS5Port", ui->socks5PortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/HTTPPort", ui->httpPortSpinBox->value());
|
||||
|
||||
@@ -390,7 +390,7 @@
|
||||
<property name="title">
|
||||
<string>EasyConnect 认证信息</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
@@ -700,6 +700,34 @@
|
||||
<string>高级</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="dnsServerBindLabel">
|
||||
<property name="text">
|
||||
<string>DNS 监听地址</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="dnsServerBindLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>留空则禁用,例如 127.0.0.1:53</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="localDnsServerLabel">
|
||||
<property name="text">
|
||||
<string>本地 DNS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="localDnsServerLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>用于解析 VPN 服务器域名,留空则使用系统 DNS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="shadowsocksUrlLineEdit">
|
||||
<property name="placeholderText">
|
||||
@@ -731,14 +759,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="dnsLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>勾选自动,否则不应留空</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="secondaryDnsLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>不填则采用系统 DNS ,使用 DNS 劫持必须填写</string>
|
||||
@@ -759,7 +787,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="2">
|
||||
<item row="1" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="dnsAutoCheckBox">
|
||||
<property name="text">
|
||||
<string>自动</string>
|
||||
@@ -807,7 +835,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel8">
|
||||
<property name="text">
|
||||
<string>DNS 服务器</string>
|
||||
@@ -821,7 +849,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel9">
|
||||
<property name="text">
|
||||
<string>备用 DNS</string>
|
||||
@@ -1125,6 +1153,8 @@
|
||||
<tabstop>serverPortSpinBox</tabstop>
|
||||
<tabstop>dnsLineEdit</tabstop>
|
||||
<tabstop>secondaryDnsLineEdit</tabstop>
|
||||
<tabstop>localDnsServerLineEdit</tabstop>
|
||||
<tabstop>dnsServerBindLineEdit</tabstop>
|
||||
<tabstop>socks5PortSpinBox</tabstop>
|
||||
<tabstop>httpPortSpinBox</tabstop>
|
||||
<tabstop>multiLineCheckBox</tabstop>
|
||||
|
||||
@@ -80,7 +80,8 @@ bool buildsCompleteCommandInCompatibleOrder()
|
||||
ConnectionProfile profile;
|
||||
profile.endpoint = {"atrust", "cas", "domain", "86-123", "vpn.example.edu", 8443};
|
||||
profile.credentials = {"alice", "secret", "TOTP", "/tmp/client.p12", "cert-secret"};
|
||||
profile.dns = {"10.0.0.1", false, "10.0.0.2", 60, true, "example.org=1.1.1.1"};
|
||||
profile.dns = {"10.0.0.1", false, "10.0.0.2", 60, true,
|
||||
"example.org=1.1.1.1", "223.5.5.5:53", "127.0.0.1:5353"};
|
||||
profile.proxy = {"127.0.0.1:1080", "127.0.0.1:1081", "ss://url", "http://direct",
|
||||
true, "example.org"};
|
||||
profile.tunnel = {true, true, true, true, true, "127.0.0.1:80/10.0.0.1:80",
|
||||
@@ -107,14 +108,16 @@ bool buildsCompleteCommandInCompatibleOrder()
|
||||
"-update-best-nodes-interval", "30",
|
||||
"-server", "vpn.example.edu",
|
||||
"-port", "8443",
|
||||
"-zju-dns-server", "10.0.0.1",
|
||||
"-remote-dns-server", "10.0.0.1",
|
||||
"-dns-ttl", "60",
|
||||
"-secondary-dns-server", "10.0.0.2",
|
||||
"-local-dns-server", "223.5.5.5:53",
|
||||
"-dns-server-bind", "127.0.0.1:5353",
|
||||
"-disable-keep-alive",
|
||||
"-keep-alive-url", "https://keepalive",
|
||||
"-bind-interface", "en0",
|
||||
"-auto-detect-interface",
|
||||
"-disable-zju-dns",
|
||||
"-disable-remote-dns",
|
||||
"-disable-server-config",
|
||||
"-proxy-all",
|
||||
"-tun-mode",
|
||||
|
||||
@@ -33,6 +33,8 @@ bool loadsSettingsIntoTypedProfile()
|
||||
settings.setValue("ZJUConnect/DNS", "10.0.0.1");
|
||||
settings.setValue("ZJUConnect/DNSAuto", false);
|
||||
settings.setValue("ZJUConnect/SecondaryDNS", "10.0.0.2");
|
||||
settings.setValue("ZJUConnect/LocalDNSServer", "223.5.5.5:53");
|
||||
settings.setValue("ZJUConnect/DNSServerBind", "127.0.0.1:5353");
|
||||
settings.setValue("ZJUConnect/DNSTTL", 60);
|
||||
settings.setValue("ZJUConnect/DisableZJUDNS", true);
|
||||
settings.setValue("ZJUConnect/CustomDNS", "example.org=1.1.1.1");
|
||||
@@ -88,6 +90,8 @@ bool loadsSettingsIntoTypedProfile()
|
||||
&& profile.dns.ttl == 60
|
||||
&& profile.dns.disableZjuDns
|
||||
&& profile.dns.custom == "example.org=1.1.1.1"
|
||||
&& profile.dns.localDnsServer == "223.5.5.5:53"
|
||||
&& profile.dns.dnsServerBind == "127.0.0.1:5353"
|
||||
&& profile.proxy.socksBind == "[::]:1080"
|
||||
&& profile.proxy.httpBind == "[::]:1081"
|
||||
&& profile.proxy.shadowsocksUrl == "ss://url"
|
||||
@@ -134,6 +138,8 @@ bool usesCompatibleDefaults()
|
||||
&& profile.behavior.disableMultiLine
|
||||
&& profile.behavior.disableKeepAlive
|
||||
&& profile.behavior.disableZjuConfig
|
||||
&& profile.dns.localDnsServer.isEmpty()
|
||||
&& profile.dns.dnsServerBind.isEmpty()
|
||||
&& !profile.debug.detailedOutput
|
||||
&& !profile.debug.capturePcap
|
||||
&& !profile.debug.exportTlsKeys
|
||||
|
||||
Reference in New Issue
Block a user