|
@@ -3,6 +3,7 @@ const https = require('https')
|
|
|
const { URL } = require('url')
|
|
|
const dns = require('dns')
|
|
|
const ipAddress = require('ip-address')
|
|
|
+const logger = require('../logger')
|
|
|
const FORBIDDEN_IP_ADDRESS = 'Forbidden IP address'
|
|
|
|
|
|
function isIPAddress (address) {
|
|
@@ -84,11 +85,13 @@ module.exports.getRedirectEvaluator = (requestURL, blockPrivateIPs) => {
|
|
|
}
|
|
|
|
|
|
const redirectURL = res.headers.location
|
|
|
- if (!redirectURL) {
|
|
|
- return false
|
|
|
+ const shouldRedirect = redirectURL ? new URL(redirectURL).protocol === protocol : false
|
|
|
+ if (!shouldRedirect) {
|
|
|
+ logger.info(
|
|
|
+ `blocking redirect from ${requestURL} to ${redirectURL}`, 'redirect.protection')
|
|
|
}
|
|
|
|
|
|
- return new URL(redirectURL).protocol === protocol
|
|
|
+ return shouldRedirect
|
|
|
}
|
|
|
}
|
|
|
|