dev-sidecar/packages/mitmproxy/src/lib/interceptor/impl/req/sni.js

17 lines
612 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

module.exports = {
requestIntercept (context, interceptOpt) {
const { rOptions, log } = context
if (interceptOpt.sni != null) {
rOptions.servername = interceptOpt.sni
if (rOptions.agent && rOptions.agent.options) {
rOptions.agent.options.rejectUnauthorized = false
}
log.info('sni intercept: sni replace servername:', rOptions.hostname, '➜', rOptions.servername)
}
return true
},
is (interceptOpt) {
return !!interceptOpt.sni && !interceptOpt.proxy // proxy生效时sni不需要生效因为proxy中也会使用sni覆盖 rOptions.servername
}
}