|
|
|
@ -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`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|