|
|
@ -33,20 +33,33 @@ if (config.trustedProxy != null) { |
|
|
|
|
|
|
|
console.log("Trusting proxy", config.trustedProxy); |
|
|
|
} else { |
|
|
|
let trusted = null |
|
|
|
|
|
|
|
setInterval(() => { |
|
|
|
dns.resolve4(config.trustedProxy, (err, res) => { |
|
|
|
if (err != null) { |
|
|
|
if (trusted === null) { |
|
|
|
console.error("Failed to resolve trustedProxy hostname") |
|
|
|
console.error(err) |
|
|
|
process.exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
if (res.length === 0) { |
|
|
|
if (trusted === null) { |
|
|
|
console.error("No results for trustedProxy hostname") |
|
|
|
process.exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (trusted !== res[0]) { |
|
|
|
console.log("Trusting proxy", res[0], `(${config.trustedProxy})`); |
|
|
|
app.set('trust proxy', res[0]) |
|
|
|
|
|
|
|
trusted = res[0] |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|