日志优化:区分代理连接和直连
parent
9fc844e939
commit
063cb4fa1d
|
@ -88,7 +88,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
|
||||||
})
|
})
|
||||||
proxySocket.on('timeout', () => {
|
proxySocket.on('timeout', () => {
|
||||||
const cost = new Date() - start
|
const cost = new Date() - start
|
||||||
const errorMsg = `代理连接超时: ${hostport}, cost: ${cost} ms`
|
const errorMsg = `${isDirect ? '直连' : '代理连接'}超时: ${hostport}, cost: ${cost} ms`
|
||||||
log.error(errorMsg)
|
log.error(errorMsg)
|
||||||
|
|
||||||
cltSocket.destroy()
|
cltSocket.destroy()
|
||||||
|
@ -102,7 +102,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
|
||||||
proxySocket.on('error', (e) => {
|
proxySocket.on('error', (e) => {
|
||||||
// 连接失败,可能被GFW拦截,或者服务端拥挤
|
// 连接失败,可能被GFW拦截,或者服务端拥挤
|
||||||
const cost = new Date() - start
|
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)
|
log.error(errorMsg)
|
||||||
|
|
||||||
cltSocket.destroy()
|
cltSocket.destroy()
|
||||||
|
@ -115,6 +115,6 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
|
||||||
})
|
})
|
||||||
return proxySocket
|
return proxySocket
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(`Proxy connect error: ${hostport}, exception:`, e)
|
log.error(`${isDirect ? '直连' : '代理连接'}错误: ${hostport}, error:`, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue