feature: 域名白名单,支持反向配置,用于大范围设置不代理,个别域名设置需要代理。
parent
5cd7792bee
commit
3f5049ad91
|
@ -54,12 +54,12 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteTarget (item, index) {
|
|
||||||
this.targets.splice(index, 1)
|
|
||||||
},
|
|
||||||
addTarget () {
|
addTarget () {
|
||||||
this.targets.unshift({ key: '', value: 'true' })
|
this.targets.unshift({ key: '', value: 'true' })
|
||||||
},
|
},
|
||||||
|
deleteTarget (item, index) {
|
||||||
|
this.targets.splice(index, 1)
|
||||||
|
},
|
||||||
saveTarget () {
|
saveTarget () {
|
||||||
const map = {}
|
const map = {}
|
||||||
for (const item of this.targets) {
|
for (const item of this.targets) {
|
||||||
|
|
|
@ -15,6 +15,16 @@ export default {
|
||||||
dnsMappings: [],
|
dnsMappings: [],
|
||||||
speedTestList: [],
|
speedTestList: [],
|
||||||
whiteList: [],
|
whiteList: [],
|
||||||
|
whiteListOptions: [
|
||||||
|
{
|
||||||
|
label: '不代理',
|
||||||
|
value: 'true',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '代理',
|
||||||
|
value: 'false',
|
||||||
|
},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -102,26 +112,26 @@ export default {
|
||||||
for (const key in this.config.server.whiteList) {
|
for (const key in this.config.server.whiteList) {
|
||||||
const value = this.config.server.whiteList[key]
|
const value = this.config.server.whiteList[key]
|
||||||
this.whiteList.push({
|
this.whiteList.push({
|
||||||
key,
|
key: key || '',
|
||||||
value,
|
value: value === true ? 'true' : 'false',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
addWhiteList () {
|
||||||
|
this.whiteList.unshift({ key: '', value: 'true' })
|
||||||
|
},
|
||||||
|
deleteWhiteList (item, index) {
|
||||||
|
this.whiteList.splice(index, 1)
|
||||||
|
},
|
||||||
submitWhiteList () {
|
submitWhiteList () {
|
||||||
const whiteList = {}
|
const whiteList = {}
|
||||||
for (const item of this.whiteList) {
|
for (const item of this.whiteList) {
|
||||||
if (item.key) {
|
if (item.key) {
|
||||||
whiteList[item.key] = item.value
|
whiteList[item.key] = item.value === 'true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.config.server.whiteList = whiteList
|
this.config.server.whiteList = whiteList
|
||||||
},
|
},
|
||||||
deleteWhiteList (item, index) {
|
|
||||||
this.whiteList.splice(index, 1)
|
|
||||||
},
|
|
||||||
addWhiteList () {
|
|
||||||
this.whiteList.unshift({ key: '', value: true })
|
|
||||||
},
|
|
||||||
getSpeedTestConfig () {
|
getSpeedTestConfig () {
|
||||||
return this.config.server.dns.speedTest
|
return this.config.server.dns.speedTest
|
||||||
},
|
},
|
||||||
|
@ -289,11 +299,18 @@ export default {
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row v-for="(item, index) of whiteList" :key="index" :gutter="10" style="margin-top: 5px">
|
<a-row v-for="(item, index) of whiteList" :key="index" :gutter="10" style="margin-top: 5px">
|
||||||
<a-col :span="21">
|
<a-col :span="16">
|
||||||
<a-input v-model="item.key" :disabled="item.value === false" />
|
<a-input v-model="item.key" />
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="5">
|
||||||
|
<a-select v-model="item.value" style="width:100%">
|
||||||
|
<a-select-option v-for="(item2) of whiteListOptions" :key="item2.value" :value="item2.value">
|
||||||
|
{{ item2.label }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="3">
|
<a-col :span="3">
|
||||||
<a-button v-if="item.value !== false" type="danger" icon="minus" @click="deleteWhiteList(item, index)" />
|
<a-button type="danger" icon="minus" @click="deleteWhiteList(item, index)" />
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
|
|
|
@ -108,7 +108,7 @@ module.exports = (serverConfig) => {
|
||||||
const hostname = req.url.split(':')[0]
|
const hostname = req.url.split(':')[0]
|
||||||
|
|
||||||
// 配置了白名单的域名,将跳过代理
|
// 配置了白名单的域名,将跳过代理
|
||||||
const inWhiteList = matchUtil.matchHostname(whiteList, hostname, 'in whiteList') != null
|
const inWhiteList = !!matchUtil.matchHostname(whiteList, hostname, 'in whiteList')
|
||||||
if (inWhiteList) {
|
if (inWhiteList) {
|
||||||
log.info(`为白名单域名,不拦截: ${hostname}, headers:`, jsonApi.stringify2(req.headers))
|
log.info(`为白名单域名,不拦截: ${hostname}, headers:`, jsonApi.stringify2(req.headers))
|
||||||
return false // 不拦截
|
return false // 不拦截
|
||||||
|
|
Loading…
Reference in New Issue