优化sni拦截器
parent
d513442c49
commit
8384b86d71
|
@ -64,7 +64,9 @@ module.exports = {
|
||||||
|
|
||||||
if (interceptOpt.sni != null) {
|
if (interceptOpt.sni != null) {
|
||||||
rOptions.servername = interceptOpt.sni
|
rOptions.servername = interceptOpt.sni
|
||||||
rOptions.agent.options.rejectUnauthorized = false
|
if (rOptions.agent) {
|
||||||
|
rOptions.agent.options.rejectUnauthorized = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,9 @@ module.exports = {
|
||||||
const { rOptions, log } = context
|
const { rOptions, log } = context
|
||||||
if (interceptOpt.sni != null) {
|
if (interceptOpt.sni != null) {
|
||||||
rOptions.servername = interceptOpt.sni
|
rOptions.servername = interceptOpt.sni
|
||||||
|
if (rOptions.agent) {
|
||||||
|
rOptions.agent.options.rejectUnauthorized = false
|
||||||
|
}
|
||||||
log.info('sni intercept: sni replace servername:', rOptions.hostname, '➜', rOptions.servername)
|
log.info('sni intercept: sni replace servername:', rOptions.hostname, '➜', rOptions.servername)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -40,7 +40,7 @@ util.getOptionsFromRequest = (req, ssl, externalProxy = null) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete headers['proxy-connection']
|
delete headers['proxy-connection']
|
||||||
let agent = false
|
let agent
|
||||||
if (!externalProxyUrl) {
|
if (!externalProxyUrl) {
|
||||||
// keepAlive
|
// keepAlive
|
||||||
if (headers.connection !== 'close') {
|
if (headers.connection !== 'close') {
|
||||||
|
@ -50,6 +50,8 @@ util.getOptionsFromRequest = (req, ssl, externalProxy = null) => {
|
||||||
agent = httpAgent
|
agent = httpAgent
|
||||||
}
|
}
|
||||||
headers.connection = 'keep-alive'
|
headers.connection = 'keep-alive'
|
||||||
|
} else {
|
||||||
|
agent = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
agent = util.getTunnelAgent(protocol === 'https:', externalProxyUrl)
|
agent = util.getTunnelAgent(protocol === 'https:', externalProxyUrl)
|
||||||
|
|
Loading…
Reference in New Issue