Fix a few common causes of error logs (incl. better ffprobe error messages)

This commit is contained in:
Calvin Montgomery 2017-12-10 16:39:06 -08:00
parent c4cc22dd05
commit fbee6d2ab7
4 changed files with 55 additions and 12 deletions

View file

@ -50,10 +50,28 @@ class IOServer {
// If the resulting address is a known Tor exit, flag it as such
ipProxyMiddleware(socket, next) {
if (!socket.context) socket.context = {};
socket.context.ipAddress = proxyaddr(socket.client.request, this.proxyTrustFn);
try {
socket.context.ipAddress = proxyaddr(
socket.client.request,
this.proxyTrustFn
);
if (!socket.context.ipAddress) {
throw new Error(
`Assertion failed: unexpected IP ${socket.context.ipAddress}`
);
}
} catch (error) {
LOGGER.warn('Rejecting socket - proxyaddr failed: %s', error);
next(new Error('Could not determine IP address'));
return;
}
if (isTorExit(socket.context.ipAddress)) {
socket.context.torConnection = true;
}
next();
}