Browse Source

optimize: `IP预设置` 功能,无需依赖 `DNS设置` 或 `IP测速` 功能,也能单独配置并生效了。

pull/355/head
王良 2 months ago
parent
commit
a58058931d
  1. 10
      packages/gui/src/view/pages/server.vue
  2. 9
      packages/gui/src/view/style/index.scss
  3. 3
      packages/gui/src/view/style/theme/dark.scss
  4. 12
      packages/mitmproxy/src/lib/dns/index.js
  5. 5
      packages/mitmproxy/src/options.js

10
packages/gui/src/view/pages/server.vue

@ -71,14 +71,14 @@
</div>
</a-tab-pane>
<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>
</a-tab-pane>
<a-tab-pane tab="超时时间设置" key="3">
<div style="height:100%;display:flex;flex-direction:column;padding-right:10px">
<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.defaultKeepAliveTimeout" :step="1000" :min="1000"/> ms对应 keepAliveTimeout 属性
请求<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,对应<span class="tip">keepAliveTimeout</span>属性
</a-form-item>
<hr style="margin-bottom:15px"/>
<div>这里指定域名的超时时间<span class="form-help">以下github的配置为示例预计将在 1.8.7 版本删除</span></div>
@ -106,13 +106,13 @@
</a-tab-pane>
<a-tab-pane tab="IP预设置" key="5">
<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"
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
</div>
</a-tab-pane>
<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>
</a-tab-pane>
<a-tab-pane tab="DNS设置" key="7">

9
packages/gui/src/view/style/index.scss

@ -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{
width: auto;
min-width: 27px;

3
packages/gui/src/view/style/theme/dark.scss

@ -24,6 +24,9 @@ $dark-input: #777; //输入框:背景色
.form-help {
color: #999
}
.tip {
color: #999;
}
/* 高亮块:背景色和字体颜色 */
/* 警告类型 */

12
packages/mitmproxy/src/lib/dns/index.js

@ -2,6 +2,7 @@ const DNSOverTLS = require('./tls.js')
const DNSOverHTTPS = require('./https.js')
const DNSOverIpAddress = require('./ipaddress.js')
const matchUtil = require('../../utils/util.match')
const log = require('../../utils/util.log')
module.exports = {
initDNS (dnsProviders, preSetIpList) {
@ -30,6 +31,17 @@ module.exports = {
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) {
return dnsConfig.providers[providerName]
}

5
packages/mitmproxy/src/options.js

@ -65,11 +65,14 @@ module.exports = (serverConfig) => {
middlewares.push(overwallMiddleware)
}
const preSetIpList = matchUtil.domainMapRegexply(serverConfig.preSetIpList)
const options = {
host: serverConfig.host,
port: serverConfig.port,
dnsConfig: {
providers: dnsUtil.initDNS(serverConfig.dns.providers, matchUtil.domainMapRegexply(serverConfig.preSetIpList)),
preSetIpList,
providers: dnsUtil.initDNS(serverConfig.dns.providers, preSetIpList),
mapping: matchUtil.domainMapRegexply(dnsMapping),
speedTest: serverConfig.dns.speedTest
},

Loading…
Cancel
Save