optimize: `IP预设置` 功能,无需依赖 `DNS设置` 或 `IP测速` 功能,也能单独配置并生效了。
parent
fc490d4463
commit
a58058931d
|
@ -71,14 +71,14 @@
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="拦截设置" key="2">
|
<a-tab-pane tab="拦截设置" key="2">
|
||||||
<vue-json-editor style="height:100%;" ref="editor" v-model="config.server.intercepts" mode="code"
|
<vue-json-editor style="height:100%" ref="editor" v-model="config.server.intercepts" mode="code"
|
||||||
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="超时时间设置" key="3">
|
<a-tab-pane tab="超时时间设置" key="3">
|
||||||
<div style="height:100%;display:flex;flex-direction:column;padding-right:10px">
|
<div style="height:100%;display:flex;flex-direction:column;padding-right:10px">
|
||||||
<a-form-item label="默认超时时间" :label-col="labelCol" :wrapper-col="wrapperCol">
|
<a-form-item label="默认超时时间" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||||
请求:<a-input-number v-model="config.server.setting.defaultTimeout" :step="1000" :min="1000"/> ms,对应 timeout 属性<br/>
|
请求:<a-input-number v-model="config.server.setting.defaultTimeout" :step="1000" :min="1000"/> ms,对应<span class="tip">timeout</span>属性<br/>
|
||||||
连接:<a-input-number v-model="config.server.setting.defaultKeepAliveTimeout" :step="1000" :min="1000"/> ms,对应 keepAliveTimeout 属性
|
连接:<a-input-number v-model="config.server.setting.defaultKeepAliveTimeout" :step="1000" :min="1000"/> ms,对应<span class="tip">keepAliveTimeout</span>属性
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<hr style="margin-bottom:15px"/>
|
<hr style="margin-bottom:15px"/>
|
||||||
<div>这里指定域名的超时时间:<span class="form-help">(以下github的配置为示例,预计将在 1.8.7 版本删除)</span></div>
|
<div>这里指定域名的超时时间:<span class="form-help">(以下github的配置为示例,预计将在 1.8.7 版本删除)</span></div>
|
||||||
|
@ -106,13 +106,13 @@
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="IP预设置" key="5">
|
<a-tab-pane tab="IP预设置" key="5">
|
||||||
<div style="height:100%;display:flex;flex-direction:column">
|
<div style="height:100%;display:flex;flex-direction:column">
|
||||||
<div>注意:IP预设置功能,需要与 `DNS设置` 或 `IP测速` 功能一起使用才会生效。</div>
|
<div>提示:<span class="tip">IP预设置</span>功能,优先级高于 <span class="tip">DNS设置</span>;域名配置可使用通配符或正则</div>
|
||||||
<vue-json-editor style="flex-grow:1;min-height:300px;margin-top:10px;" ref="editor" v-model="config.server.preSetIpList" mode="code"
|
<vue-json-editor style="flex-grow:1;min-height:300px;margin-top:10px;" ref="editor" v-model="config.server.preSetIpList" mode="code"
|
||||||
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="DNS服务管理" key="6">
|
<a-tab-pane tab="DNS服务管理" key="6">
|
||||||
<vue-json-editor style="height:100%;" ref="editor" v-model="config.server.dns.providers" mode="code"
|
<vue-json-editor style="height:100%" ref="editor" v-model="config.server.dns.providers" mode="code"
|
||||||
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="DNS设置" key="7">
|
<a-tab-pane tab="DNS设置" key="7">
|
||||||
|
|
|
@ -56,6 +56,15 @@ ol{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tip {
|
||||||
|
color: #aaa;
|
||||||
|
font-family: "Microsoft YaHei", serif;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.ace_search_form .ace_searchbtn{
|
.ace_search_form .ace_searchbtn{
|
||||||
width: auto;
|
width: auto;
|
||||||
min-width: 27px;
|
min-width: 27px;
|
||||||
|
|
|
@ -24,6 +24,9 @@ $dark-input: #777; //输入框:背景色
|
||||||
.form-help {
|
.form-help {
|
||||||
color: #999
|
color: #999
|
||||||
}
|
}
|
||||||
|
.tip {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
/* 高亮块:背景色和字体颜色 */
|
/* 高亮块:背景色和字体颜色 */
|
||||||
/* 警告类型 */
|
/* 警告类型 */
|
||||||
|
|
|
@ -2,6 +2,7 @@ const DNSOverTLS = require('./tls.js')
|
||||||
const DNSOverHTTPS = require('./https.js')
|
const DNSOverHTTPS = require('./https.js')
|
||||||
const DNSOverIpAddress = require('./ipaddress.js')
|
const DNSOverIpAddress = require('./ipaddress.js')
|
||||||
const matchUtil = require('../../utils/util.match')
|
const matchUtil = require('../../utils/util.match')
|
||||||
|
const log = require('../../utils/util.log')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
initDNS (dnsProviders, preSetIpList) {
|
initDNS (dnsProviders, preSetIpList) {
|
||||||
|
@ -30,6 +31,17 @@ module.exports = {
|
||||||
providerName = 'cloudflare'
|
providerName = 'cloudflare'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果为空,尝试从预设IP中匹配,如果配置过预设IP,则随便
|
||||||
|
if (providerName == null) {
|
||||||
|
const hostnamePreSetIpList = matchUtil.matchHostname(dnsConfig.preSetIpList, hostname, 'matched preSetIpList')
|
||||||
|
if (hostnamePreSetIpList) {
|
||||||
|
for (const name in dnsConfig.providers) {
|
||||||
|
log.debug(`当前域名未配置过DNS,但配置了预设IP,现返回DNS '${name}' 作为预设IP的使用工具,hostname: ${hostname}, preSetIpList:`, hostnamePreSetIpList)
|
||||||
|
return dnsConfig.providers[name]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (providerName) {
|
if (providerName) {
|
||||||
return dnsConfig.providers[providerName]
|
return dnsConfig.providers[providerName]
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,14 @@ module.exports = (serverConfig) => {
|
||||||
middlewares.push(overwallMiddleware)
|
middlewares.push(overwallMiddleware)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const preSetIpList = matchUtil.domainMapRegexply(serverConfig.preSetIpList)
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
host: serverConfig.host,
|
host: serverConfig.host,
|
||||||
port: serverConfig.port,
|
port: serverConfig.port,
|
||||||
dnsConfig: {
|
dnsConfig: {
|
||||||
providers: dnsUtil.initDNS(serverConfig.dns.providers, matchUtil.domainMapRegexply(serverConfig.preSetIpList)),
|
preSetIpList,
|
||||||
|
providers: dnsUtil.initDNS(serverConfig.dns.providers, preSetIpList),
|
||||||
mapping: matchUtil.domainMapRegexply(dnsMapping),
|
mapping: matchUtil.domainMapRegexply(dnsMapping),
|
||||||
speedTest: serverConfig.dns.speedTest
|
speedTest: serverConfig.dns.speedTest
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue