日志优化:区分代理连接和直连

pull/384/head
王良 2024-10-22 09:36:15 +08:00
parent 9fc844e939
commit 063cb4fa1d
1 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
})
proxySocket.on('timeout', () => {
const cost = new Date() - start
const errorMsg = `代理连接超时: ${hostport}, cost: ${cost} ms`
const errorMsg = `${isDirect ? '直连' : '代理连接'}超时: ${hostport}, cost: ${cost} ms`
log.error(errorMsg)
cltSocket.destroy()
@ -102,7 +102,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
proxySocket.on('error', (e) => {
// 连接失败可能被GFW拦截或者服务端拥挤
const cost = new Date() - start
const errorMsg = `代理连接失败: ${hostport}, cost: ${cost} ms, errorMsg: ${e.message}`
const errorMsg = `${isDirect ? '直连' : '代理连接'}失败: ${hostport}, cost: ${cost} ms, errorMsg: ${e.message}`
log.error(errorMsg)
cltSocket.destroy()
@ -115,6 +115,6 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
})
return proxySocket
} catch (e) {
log.error(`Proxy connect error: ${hostport}, exception:`, e)
log.error(`${isDirect ? '直连' : '代理连接'}错误: ${hostport}, error:`, e)
}
}