Browse Source

日志优化

pull/376/head
王良 1 month ago
parent
commit
9b13575ba1
  1. 14
      packages/mitmproxy/src/utils/util.match.js

14
packages/mitmproxy/src/utils/util.match.js

@ -62,17 +62,17 @@ function matchHostname (hostMap, hostname, action) {
// 域名快速匹配:直接匹配 或者 两种前缀通配符匹配
let value = hostMap.origin[hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}
value = hostMap.origin['*' + hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "*${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}
value = hostMap.origin['*.' + hostname]
if (value) {
log.info(`matchHostname: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
log.info(`matchHostname: ${action}: '${hostname}' -> { "*.${hostname}": ${JSON.stringify(value)} }`)
return value // 快速匹配成功
}
@ -145,7 +145,7 @@ function matchHostnameAll (hostMap, hostname, action) {
// 正则表达式匹配
if (hostname.match(regexp)) {
value = hostMap[target]
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '${target}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "${target}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
}
@ -154,19 +154,19 @@ function matchHostnameAll (hostMap, hostname, action) {
// 优先级:2
value = hostMap.origin['*' + hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '*${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "*${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
// 优先级:3
value = hostMap.origin['*.' + hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '*.${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "*.${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}
// 优先级:4,最高(注:优先级高的配置,可以覆盖优先级低的配置,甚至有空配置时,可以移除已有配置)
value = hostMap.origin[hostname]
if (value) {
log.debug(`matchHostname-one: ${action}: '${hostname}' -> '${hostname}': ${JSON.stringify(value)}`)
log.debug(`matchHostname-one: ${action}: '${hostname}' -> { "${hostname}": ${JSON.stringify(value)} }`)
values = merge(values, value)
}

Loading…
Cancel
Save