日志小调整。

pull/287/head
王良 8 months ago
parent 15d4a88e15
commit 8b54345bc1

@ -4,7 +4,7 @@ const log = require('../../../utils/util.log')
const DnsUtil = require('../../dns/index')
const localIP = '127.0.0.1'
const defaultDns = require('dns')
const matchUtil = require('../../../utils/util.match')
// const matchUtil = require('../../../utils/util.match')
const speedTest = require('../../speed/index.js')
function isSslConnect (sslConnectInterceptors, req, cltSocket, head) {
for (const intercept of sslConnectInterceptors) {
@ -31,7 +31,7 @@ module.exports = function createConnectHandler (sslConnectInterceptor, middlewar
}
console.log('sni config', sniConfig)
const sniRegexpMap = matchUtil.domainMapRegexply(sniConfig)
// const sniRegexpMap = matchUtil.domainMapRegexply(sniConfig)
return function connectHandler (req, cltSocket, head) {
// eslint-disable-next-line node/no-deprecated-api
const srvUrl = url.parse(`https://${req.url}`)
@ -45,12 +45,12 @@ module.exports = function createConnectHandler (sslConnectInterceptor, middlewar
})
} else {
log.info('不拦截请求:', hostname)
connect(req, cltSocket, head, hostname, srvUrl.port, dnsConfig, sniRegexpMap)
connect(req, cltSocket, head, hostname, srvUrl.port, dnsConfig/*, sniRegexpMap */)
}
}
}
function connect (req, cltSocket, head, hostname, port, dnsConfig, sniRegexpMap) {
function connect (req, cltSocket, head, hostname, port, dnsConfig/*, sniRegexpMap */) {
// tunneling https
// log.info('connect:', hostname, port)
const start = new Date().getTime()

@ -110,7 +110,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
function onFree () {
const url = `${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${rOptions.path}`
const start = new Date().getTime()
log.info('代理请求:', url, rOptions.method)
log.info('代理请求:', url, rOptions.method, rOptions.servername ? ', sni: ' + rOptions.servername : '')
let isDnsIntercept
if (dnsConfig) {
const dns = DnsUtil.hasDnsLookup(dnsConfig, rOptions.hostname)

@ -106,14 +106,14 @@ function deleteNullItems (target) {
}
function matchHostnameAll (hostMap, hostname, action) {
// log.debug('matchHostnameAll:', action, hostMap)
// log.debug('matchHostname-all:', action, hostMap)
if (hostMap == null) {
log.warn(`matchHostnameAll: ${action}: '${hostname}', hostMap is null`)
log.warn(`matchHostname-all: ${action}: '${hostname}', hostMap is null`)
return null
}
if (hostMap.origin == null) {
log.warn(`matchHostnameAll: ${action}: '${hostname}', hostMap.origin is null`)
log.warn(`matchHostname-all: ${action}: '${hostname}', hostMap.origin is null`)
return null
}
@ -139,7 +139,7 @@ function matchHostnameAll (hostMap, hostname, action) {
// 正则表达式匹配
if (hostname.match(regexp)) {
value = hostMap[target]
log.info(`matchHostnameOne: ${action}: '${hostname}' -> '${target}': ${JSON.stringify(value)}`)
log.info(`matchHostname-one: ${action}: '${hostname}' -> '${target}': ${JSON.stringify(value)}`)
values = merge(values, value)
}
}
@ -148,28 +148,28 @@ function matchHostnameAll (hostMap, hostname, action) {
// 优先级2
value = hostMap.origin['*' + hostname]
if (value) {
log.info(`matchHostnameOne: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname-one: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
values = merge(values, value)
}
// 优先级3
value = hostMap.origin['*.' + hostname]
if (value) {
log.info(`matchHostnameOne: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname-one: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
values = merge(values, value)
}
// 优先级4最高优先级高的配置可以覆盖优先级低的配置甚至有空配置时可以移除已有配置
value = hostMap.origin[hostname]
if (value) {
log.info(`matchHostnameOne: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname-one: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
values = merge(values, value)
}
if (!lodash.isEmpty(values)) {
deleteNullItems(values)
log.info(`matchHostnameAll: ${action}: '${hostname}':`, JSON.stringify(values))
log.info(`matchHostname-all: ${action}: '${hostname}':`, JSON.stringify(values))
return values
} else {
log.debug(`matchHostnameAll: ${action}: '${hostname}' Not-Matched`)
log.debug(`matchHostname-all: ${action}: '${hostname}' Not-Matched`)
}
}

Loading…
Cancel
Save