Browse Source

server: Added resilience to trust proxy resolution to handle IP changes and bad start order.

1.2 1.2.5
Gisle Aune 6 years ago
parent
commit
624f7046af
  1. 19
      server.js

19
server.js

@ -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)
}
}

Loading…
Cancel
Save