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

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.51.7", "version": "3.51.8",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -64,7 +64,7 @@ class ReferenceCounter {
for (var caller in this.references) { for (var caller in this.references) {
this.refCount += this.references[caller]; this.refCount += this.references[caller];
} }
} else if (this.channel.users.length > 0) { } else if (this.channel.users && this.channel.users.length > 0) {
LOGGER.error("ReferenceCounter::refCount reached 0 but still had " + LOGGER.error("ReferenceCounter::refCount reached 0 but still had " +
this.channel.users.length + " active users" + this.channel.users.length + " active users" +
` (channel: ${this.channelName})`); ` (channel: ${this.channelName})`);

View File

@ -7,6 +7,37 @@ var urlparse = require("url");
var path = require("path"); var path = require("path");
const LOGGER = require('@calzoneman/jsli')('ffmpeg'); const LOGGER = require('@calzoneman/jsli')('ffmpeg');
const ECODE_MESSAGES = {
ENOTFOUND: e => (
`Unknown host "${e.hostname}". ` +
'Please check that the link is correct.'
),
EPROTO: e => 'The remote server does not support HTTPS.',
ECONNREFUSED: e => (
'The remote server refused the connection. ' +
'Please check that the link is correct and the server is running.'
),
ETIMEDOUT: e => (
'The connection to the remote server timed out. ' +
'Please check that the link is correct.'
),
ENETUNREACH: e => (
"The remote server's network is unreachable from this server. " +
"Please contact an administrator for assistance."
),
DEPTH_ZERO_SELF_SIGNED_CERT: e => (
'The remote server provided an invalid ' +
'(self-signed) SSL certificate. Raw file support requires a ' +
'trusted certificate. See https://letsencrypt.org/ to get ' +
'a free, trusted certificate.'
),
UNABLE_TO_VERIFY_LEAF_SIGNATURE: e => (
"The remote server's SSL certificate chain could not be validated. " +
"Please contact the administrator of the server to correct their " +
"SSL certificate configuration."
)
};
var USE_JSON = true; var USE_JSON = true;
var TIMEOUT = 30000; var TIMEOUT = 30000;
@ -138,18 +169,12 @@ function testUrl(url, cb, params = { redirCount: 0, cookie: '' }) {
cb("The remote server provided an invalid SSL certificate. Details: " cb("The remote server provided an invalid SSL certificate. Details: "
+ err.reason); + err.reason);
return; return;
} else if (err.code === 'ENOTFOUND') { } else if (ECODE_MESSAGES.hasOwnProperty(err.code)) {
cb(`Unknown host "${err.hostname}". Please check that the link is correct.`); cb(`${ECODE_MESSAGES[err.code](err)} (error code: ${err.code})`);
return;
} else if (err.code === 'ECONNREFUSED') {
cb("The remote server refused the connection. Please check that the link is correct.");
return;
} else if (err.code === 'ETIMEDOUT') {
cb("The connection to the remote server timed out. Please check that the link is correct.");
return; return;
} }
LOGGER.error("Error sending preflight request: %s (link: %s)", err.message, url); LOGGER.error("Error sending preflight request: %s (code=%s) (link: %s)", err.message, err.code, url);
cb("An unexpected error occurred while trying to process the link. " + cb("An unexpected error occurred while trying to process the link. " +
"Try again, and contact support for further troubleshooting if the " + "Try again, and contact support for further troubleshooting if the " +
"problem continues." + (!!err.code ? (" Error code: " + err.code) : "")); "problem continues." + (!!err.code ? (" Error code: " + err.code) : ""));

View File

@ -50,10 +50,28 @@ class IOServer {
// If the resulting address is a known Tor exit, flag it as such // If the resulting address is a known Tor exit, flag it as such
ipProxyMiddleware(socket, next) { ipProxyMiddleware(socket, next) {
if (!socket.context) socket.context = {}; 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)) { if (isTorExit(socket.context.ipAddress)) {
socket.context.torConnection = true; socket.context.torConnection = true;
} }
next(); next();
} }