refactor: 支持配置端口

pull/67/head
xiaojunnuo 2021-03-31 18:42:04 +08:00
parent 014d2027e9
commit 8317b6a734
3 changed files with 12 additions and 8 deletions

View File

@ -1,10 +1,10 @@
module.exports = { module.exports = {
name: '梯子', name: '梯子',
enabled: false, // 默认关闭梯子 enabled: false, // 默认关闭梯子
server: { server: {},
},
serverDefault: { serverDefault: {
'ow-prod.docmirror.top': { 'ow-prod.docmirror.top': {
port: 443,
path: 'X2dvX292ZXJfd2FsbF8', path: 'X2dvX292ZXJfd2FsbF8',
password: 'dev_sidecar_is_666' password: 'dev_sidecar_is_666'
} }

View File

@ -53,13 +53,16 @@
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="10" v-for="(item,index) of servers" :key = 'index'> <a-row :gutter="10" v-for="(item,index) of servers" :key = 'index'>
<a-col :span="8"> <a-col :span="6">
<a-input addon-before="" placeholder="yourdomain.com" v-model="item.key"></a-input> <a-input addon-before="" placeholder="yourdomain.com" v-model="item.key"/>
</a-col> </a-col>
<a-col :span="7"> <a-col :span="5">
<a-input addon-before="" placeholder="443" v-model="item.value.port"/>
</a-col>
<a-col :span="6">
<a-input addon-before="" placeholder="xxxxxx" v-model="item.value.path"/> <a-input addon-before="" placeholder="xxxxxx" v-model="item.value.path"/>
</a-col> </a-col>
<a-col :span="7"> <a-col :span="5">
<a-input addon-before="" type="password" placeholder="password" v-model="item.value.password"/> <a-input addon-before="" type="password" placeholder="password" v-model="item.value.password"/>
</a-col> </a-col>
<a-col :span="2"> <a-col :span="2">

View File

@ -1,7 +1,7 @@
const url = require('url') const url = require('url')
const pac = require('./source/pac') const pac = require('./source/pac')
const matchUtil = require('../../../utils/util.match') const matchUtil = require('../../../utils/util.match')
const lodash = require('lodash')
function matched (hostname, regexpMap) { function matched (hostname, regexpMap) {
const ret1 = matchUtil.matchHostname(regexpMap, hostname) const ret1 = matchUtil.matchHostname(regexpMap, hostname)
if (ret1) { if (ret1) {
@ -63,6 +63,7 @@ module.exports = function createOverWallIntercept (overWallConfig) {
} }
const domain = proxyServer const domain = proxyServer
const port = server[domain].port
const path = server[domain].path const path = server[domain].path
const password = server[domain].password const password = server[domain].password
const proxyTarget = domain + '/' + path + '/' + hostname + req.url const proxyTarget = domain + '/' + path + '/' + hostname + req.url
@ -80,7 +81,7 @@ module.exports = function createOverWallIntercept (overWallConfig) {
} }
rOptions.path = URL.path rOptions.path = URL.path
if (URL.port == null) { if (URL.port == null) {
rOptions.port = rOptions.protocol === 'https:' ? 443 : 80 rOptions.port = port || (rOptions.protocol === 'https:' ? 443 : 80)
} }
log.info('OverWall:', rOptions.hostname, proxyTarget) log.info('OverWall:', rOptions.hostname, proxyTarget)
if (context.requestCount) { if (context.requestCount) {