V2 final debug.

This commit is contained in:
Valentin Boettcher 2017-08-08 00:54:55 +02:00
parent 066cfb2014
commit c766f6605e
18 changed files with 1051 additions and 817 deletions

496
#main.js#
View file

@ -1,496 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Main Module - Communicates with the Server and Orchestrates the other Moules. //
///////////////////////////////////////////////////////////////////////////////////
const sock = require('socket.io-client');
const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
const path = require('path');
const fs = require('fs');
const WMStrm = require(__dirname + '/lib/memWrite.js');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const spawnP = require('child_process').spawn;
/**
* Custom Modules
* Yet to be initialized.
*/
const logger = require('src/logger.js');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// Force a Stop.
let mustBe = false;
// Restart the stream after it stopped.
let restart = false;
// Central State Variable
// NOTE: Could be done with redux!
let status = {
status: 0,
error: -1
}
// Minor declarations.
let config, source, snapSource, stopTimeout;
let spawn = function() {
source = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.camProfile;
ffmpeg.setFfmpegPath(config.ffmpegPath);
delete cmd;
cmd = ffmpeg({
source: source,
stdoutLines: 20
});
if (config.customOutputOptions !== "")
cmd.outputOptions(config.customOutputOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
if (config.customAudioOptions !== "")
cmd.outputOptions(config.customAudioOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.AudioCodec('copy');
if (config.customVideoOptions !== "")
cmd.outputOptions(config.customVideoOptions.replace(/\s+\,\s+/g, ',').replace(/\s+\-/g, ',-').split(','));
else
cmd.videoCodec('copy');
cmd.on('start', function(commandLine) {
status.running = 0;
logger.log(logger.importance[4], 'Spawned Ffmpeg with command: ' + commandLine);
})
.on('end', function(o, e) {
imDead('Normal Stop.', e);
})
.on('error', function(err, o, e) {
if (err.message.indexOf(source) > -1)
criticalProblem(0, e, handleDisc, config.camIP, config.camPort);
else if (err.message.indexOf(source + 'Input/output error') > -1 || err.message.indexOf('rtmp://a.rtmp.youtube.com/live2/' + config.key) > -1)
criticalProblem(1, e, handleDisc, 'a.rtmp.youtube.com/live2/', 1935);
else if (err.message.indexOf('spawn') > -1 || err.message.indexOf('niceness') > -1)
criticalProblem(2, e, function() {});
else if (err.message.indexOf('SIGINT') > -1 || err.message.indexOf('SIGKILL') > -1)
imDead('Normal Stop.', e);
else
imDead(err.message, e);
})
.outputFormat('flv')
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config.key);
status.error = -1;
socket.emit('change', {
type: 'startStop',
change: {
running: 0,
error: -1
}
});
cmd.run();
};
let getSnap = function(cb) {
snapSource = 'rtsp://' + config.camIP + ':' + config.camPort + '/' + config.snapProfile;
let picBuff = new WMStrm();
recCmd = ffmpeg(snapSource)
.on('start', function(commandLine) {
logger.log(logger.importance[4], 'Snapshot ' + commandLine);
})
.on('error', function(err, o, e) {})
.outputFormat('mjpeg')
.frames(1)
.stream(picBuff, {
end: true
});
picBuff.on('finish', function() {
try {
cb(picBuff.memStore.toString('base64'));
delete pickBuff;
} catch (e) {
cb(false);
}
});
}
function imDead(why, e = '') {
if (stopTimeout) {
clearTimeout(stopTimeout);
stopTimeout = false;
}
status.running = 1;
socket.emit('change', {
type: 'startStop',
change: {
running: 1
}
});
if (restart) {
spawn();
restart = false;
}
if (!mustBe) {
logger.log(logger.importance[2], 'Crash! ' + e);
setTimeout(function() {
spawn();
}, 1000);
}
mustBe = false;
}
function criticalProblem(err, e, handler, ...args) {
if (!mustBe) {
setTimeout(function() {
status.running = 2;
status.error = err;
logger.log(logger.importance[3], 'Critical Problem: ' + errors[err] + '\n' + e);
socket.emit('change', {
type: 'error',
change: {
running: 2,
error: err
}
});
handler(args)
}, 1000);
}
mustBe = false;
}
function handleDisc(info) {
let [host, port] = info;
isReachable(host, port, is => {
if (is) {
spawn();
} else {
setTimeout(function() {
handleDisc(info);
}, 10000);
}
});
}
function isReachable(host, port, callback) {
http.get({
host: host.split('/')[0],
port: port
}, function(res) {
callback(true);
}).on("error", function(e) {
if (e.message == "socket hang up") {
setTimeout(function() {
callback(true);
}, 1000);
} else
callback(false);
});
}
function stopFFMPEG() {
cmd.kill('SIGINT');
stopTimeout = setTimeout(() => {
logger.log(logger.importance[3], "Force Stop!");
cmd.kill();
}, 3000);
}
var commandHandlers = function commandHandlers(command, cb) {
var handlers = {
startStop: function() {
if (restart)
return;
if (status.running !== 2)
if (status.running === 0) {
logger.log(logger.importance[1], "Stop Command!");
mustBe = true;
stopFFMPEG();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Stopped!'
}
}, command.sender);
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Started!'
}
}, command.sender);
}
},
snap: function() {
getSnap(snap => {
socket.emit('data', {
type: 'snap',
data: snap,
}, command.sender);
});
},
config: function() {
socket.emit('data', {
type: 'config',
data: config,
}, command.sender);
},
changeSettings: function() {
for (let set in command.data) {
if (typeof config[set] !== 'undefined')
config[set] = command.data[set];
}
let oldConfigured;
if (config.configured === true)
oldConfigured = true;
config.configured = true;
fs.writeFile(__dirname + '/config.js',
JSON.stringify(config,
undefined, 2),
function(err) {
if (err) {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Can\'t save the Settings!\n' + err.message
}
}, command.sender);
} else {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Settings Saved!'
}
}, command.sender);
if (oldConfigured) {
socket.emit('change', {
type: 'settings',
change: {
config: command.data
}
});
stopFFMPEG();
spawn();
} else {
socket.disconnect();
init();
}
});
}
});
},
restart: function() {
if (status.running === 0) {
logger.log(logger.importance[1], "Restart Command!");
mustBe = true;
restart = true;
stopFFMPEG();
} else {
logger.log(logger.importance[1], "Start Command!");
spawn();
}
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted!'
}
}, command.sender);
},
restartSSH: function() {
restartSSH(() => {
socket.emit('data', {
type: 'message',
data: {
title: 'Success',
type: 'success',
text: 'Restarted SSH Tunnels!'
}
}, command.sender);
});
},
getLogs: function() {
logger.query({
limit: 100
}, function(err, data) {
data = data.file;
if (err) {
data = [];
} else
if (data.length === 0)
data = [];
socket.emit('data', {
type: 'logs',
data: data
}, command.sender);
});
}
};
//call the handler
var call = handlers[command.command];
if (call)
call();
}
function restartSSH(cb) {
exec('forever stop SSH-Serv', () => {
connectSSH(() => {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
cb();
});
});
}
function handleKill() {
process.stdin.resume();
logger.log(logger.importance[0], "Received Shutdown Command");
mustBe = true;
cmd.kill();
process.exit(0);
}
process.on('SIGTERM', function() {
handleKill();
});
//let's go
function init() {
config = readConfig();
if (config.configured) {
socket = sock(config.master + '/pi');
initSocket();
status.name = config.name;
if (!cmd)
spawn();
} else {
socket = sock(config.master + '/pi', {
query: "unconfigured=true"
});
status.running = 2;
initSocket();
}
}
function initSSH(cb) {
status.ssh = {
// that Could come from the Master server!
user: config['ssh-user'],
localUser: config['ssh-local-user'],
masterPort: config['ssh-port']
};
checkSSH((alive) => {
if (alive)
cb();
else
connectSSH(cb);
});
}
function connectSSH(cb = function() {
socket.emit('change', {
change: {
ssh: {
port: status.ssh.port,
camForwardPort: status.ssh.camForwardPort
}
}
});
}) {
socket.emit('getSSHPort', ports => {
[status.ssh.port, status.ssh.camForwardPort] = ports;
let ssh = exec(`forever start -a --killSignal=SIGINT --uid SSH-Serv sshManager.js ${status.ssh.port} ${status.ssh.camForwardPort} ${config.camPanelPort}`, {
detached: true,
shell: true,
cwd: __dirname
});
ssh.on('error', (err) => {
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Could not start SSH tunnels!'
}
}, command.sender);
});
cb();
});
}
function checkSSH(cb) {
let m, pid, alive;
let re = /SSH-Serv.*?sshManager\.js\s([0-9]+)\s([0-9]+).*log.*[^STOPPED]+/g;
exec('forever list', (error, stdout, stderr) => {
if (error)
throw error;
let alive = false;
while ((m = re.exec(stdout)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
if (alive) {
exec('forever stop SSH-Serv');
cb(false)
return;
} else {
[, status.ssh.port, status.ssh.camForwardPort] = m;
alive = true;
}
}
cb(alive);
});
}
function initSocket() {
socket.on('connect', function() {
logger.log(logger.importance[0], 'Connected to Master: ' + config.master + '.');
if (config['ssh-user'])
initSSH(err => {
if (err)
throw err;
socket.emit('meta', status);
});
else {
socket.emit('meta', status);
}
});
socket.on('disconnect', function() {
socket.disconnect();
init();
});
socket.on('command', (command, cb) => {
commandHandlers(command, cb);
});
}
function readConfig() {
return JSON.parse(fs.readFileSync(__dirname + '/config.js'));
}
init();

View file

@ -1 +1 @@
35749
36875

View file

@ -7,14 +7,15 @@
"key": "upjm-kz0g-c3wt-7zuj",
"name": "Uncdonfigured",
"master": "http://localhost:8080",
"ssh-master": "localhost",
"sshMaster": "localhost",
"ffmpegPath": "ffmpeg",
"ssh": false,
"ssh-user": "ssh",
"ssh-local-user": "alarm",
"ssh-port": 22,
"sshUser": "ssh",
"sshLocalUser": "alarm",
"sshPort": 22,
"customOutputOptions": "",
"customVideoOptions": "",
"customAudioOptions": "-b:a 128k -ac 1 -ar 11025 -acodec libmp3lame",
"configured": true
"configured": true,
"ssh": true
}

1
extras/.#sshManager.js Symbolic link
View file

@ -0,0 +1 @@
hiro@Lobsang.15882:1499527133

View file

@ -43,9 +43,9 @@ server.on('create_tunnel', (data, socket) => {
let replySuccess = generateRelyFunction('success', socket, id);
let replyError = generateRelyFunction('error', socket, id);
let tunnel;
tunnel = tunnels[data.localPort];
// If the tunnel already runs:
if (tunnel && (tunnel.info.localHost === 'localhost' || tunnel.info.localHost === data.localHost)){
return replySuccess(tunnel.info.remotePort);
@ -62,7 +62,7 @@ server.on('create_tunnel', (data, socket) => {
return createNewTunnel(data).then((tunnel) => {
tunnels[tunnel.info.localPort] = tunnel;
replySuccess(tunnel.info.remotePort);
console.log("Created Tunnel:\n", tunnel);
console.log("Created Tunnel:\n", JSON.stringify(tunnel));
}, (error) => {
console.error("Tunnel Creation Failed:\n", error);
replyError(error);

46
grep Normal file
View file

@ -0,0 +1,46 @@
error: unknown option `ammend'
usage: git commit [<options>] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options
-F, --file <file> read message from file
--author <author> override author for commit
--date <date> override date for commit
-m, --message <message>
commit message
-c, --reedit-message <commit>
reuse and edit message from specified commit
-C, --reuse-message <commit>
reuse message from specified commit
--fixup <commit> use autosquash formatted message to fixup specified commit
--squash <commit> use autosquash formatted message to squash specified commit
--reset-author the commit is authored by me now (used with -C/-c/--amend)
-s, --signoff add Signed-off-by:
-t, --template <file>
use specified template file
-e, --edit force edit of commit
--cleanup <default> how to strip spaces and #comments from message
--status include status in commit message template
-S, --gpg-sign[=<key-id>]
GPG sign commit
Commit contents options
-a, --all commit all changed files
-i, --include add specified files to index for commit
--interactive interactively add files
-p, --patch interactively add changes
-o, --only commit only specified files
-n, --no-verify bypass pre-commit and commit-msg hooks
--dry-run show what would be committed
--short show status concisely
--branch show branch information
--porcelain machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
--amend amend previous commit
--no-post-rewrite bypass post-rewrite hook
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)

View file

@ -1,31 +0,0 @@
module.exports = function (settings) {
let source = 'rtsp://' + settings.camIP + ':' + settings.camPort + '/' + settings.camProfile
return ffmpeg(source)
.videoCodec('copy')
.audioBitrate('128k')
.audioChannels(1)
.audioFrequency(11025)
.audioCodec('libmp3lame')
.on('start', function (commandLine) {
settings.running = true
wLog('Spawned Ffmpeg with command: ' + commandLine, 4);
socket.emit('startStop', true)
})
.on('end', function (o, e) {
imDead('Normal Stop.', e);
})
.on('error', function (err, o, e) {
console.log(err);
if (err.message.indexOf(source + ': No route to host') > -1 || err.message.indexOf(source + ': Connection refused') > -1)
criticalProblem('Camera Disconnected', handleDisc, settings.camIP, settings.camPort)
else
if (err.message.indexOf(source + 'Input/output error') > -1)
criticalProblem('YoutTube Disconnected', handleDisc, 'rtmp://a.rtmp.youtube.com/live2/')
else
imDead(err.message, e);
})
.outputFormat('flv')
.outputOptions(['-bufsize 10000k', '-tune film'])
cmd.output('rtmp://a.rtmp.youtube.com/live2/' + settings.key);
}

474
logs/process1.log Normal file
View file

@ -0,0 +1,474 @@
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-09T13:54:24.734Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-09T13:58:15.788Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-09T13:58:15.813Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-09T13:58:15.886Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-09T13:58:15.888Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-09T13:58:16.095Z"}
{"level":"info","message":"Setting SSH ports to [object Object]","timestamp":"2017-07-09T13:58:17.001Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-09T13:58:17.002Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55fe61d6a540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-09T14:00:26.546Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-09T14:00:26.549Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-09T14:02:24.737Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-09T14:02:24.788Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-09T14:02:24.851Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-09T14:02:24.852Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 42383","timestamp":"2017-07-09T14:02:24.975Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-09T14:02:24.985Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-09T14:02:25.018Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:04:58.226Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:04:58.251Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:04:58.388Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:05:35.816Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:05:35.817Z"}
{"level":"danger","message":"An (SSH) error has occured: Command failed: ssh -NR 10000:localhost:22 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=1 hiro@localhost\nstty: 'standard input': Inappropriate ioctl for device\n\u001b[91mcould not connect to remote: dial tcp [::1]:22: getsockopt: connection refused\u001b[0m\r\nssh_exchange_identification: Connection closed by remote host\r\n","timestamp":"2017-07-19T17:05:36.395Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:05:41.709Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T17:05:41.710Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:05:51.727Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:05:53.757Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:05:53.757Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55f6908db540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T17:07:13.230Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5573.","timestamp":"2017-07-19T17:07:13.231Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:07:37.754Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:07:37.779Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:07:37.843Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:07:37.844Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:07:37.869Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:07:37.870Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:07:37.906Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:08:17.514Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:08:17.524Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:08:17.545Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:08:28.096Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:08:53.515Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:08:53.520Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:08:53.537Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:08:53.537Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:08:55.661Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:08:55.662Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x557b0cd37540] Connection to tcp://mpv.cdn3.bigCDN.com:5573?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5573/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T17:09:46.830Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T17:09:46.831Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:09:46.976Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:09:46.987Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:10:03.360Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:10:03.362Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:10:03.378Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:11:02.108Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:11:02.133Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:11:02.201Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:11:02.203Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:11:02.266Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:11:02.314Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:11:02.315Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:11:59.930Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:11:59.962Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:12:00.042Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:12:00.043Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:12:00.116Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:12:00.156Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:12:00.157Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:12:15.264Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:12:15.272Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:12:15.297Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:16:20.534Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:16:20.559Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:16:20.625Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:16:20.626Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:16:20.677Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 45393","timestamp":"2017-07-19T17:16:20.734Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:16:20.735Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:16:58.853Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:16:58.865Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:16:58.884Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:16:58.885Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:16:58.900Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43071","timestamp":"2017-07-19T17:17:01.015Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:17:01.016Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:21:07.653Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T17:21:07.654Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:21:51.937Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:21:51.962Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:21:52.010Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:22:18.188Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:22:18.214Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:22:18.292Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:22:18.293Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:22:18.350Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:22:18.726Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-07-19T17:22:18.728Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:23:23.910Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:23:23.935Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:23:23.993Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:23.994Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:23:24.059Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T17:23:24.446Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-07-19T17:23:24.447Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:29.459Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:23:31.490Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:23:31.491Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:23:35.290Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:23:35.291Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:23:37.304Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:23:37.304Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:10.279Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:10.303Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:10.366Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:10.367Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:10.434Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:10.476Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:10.477Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:24.369Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:24.393Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:24.480Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:24.481Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:24.495Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:24.495Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:24.526Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:25:47.835Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:25:47.865Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:25:47.937Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:25:47.938Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:25:48.007Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:25:48.049Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:25:48.049Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:26:40.872Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:26:40.896Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:26:40.957Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:26:40.958Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:26:41.019Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:26:41.065Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:26:41.065Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:27:13.233Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:27:13.266Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:27:13.343Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:27:13.344Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:27:13.417Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:27:13.452Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:27:13.452Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:27:30.030Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:27:30.054Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:27:30.130Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:27:30.131Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:27:30.160Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:27:30.238Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:27:30.239Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:29:11.389Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:29:11.413Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:29:11.474Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:29:11.475Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:29:11.544Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:29:11.587Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:29:11.587Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:30:31.537Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:30:31.568Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:30:31.635Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:30:31.637Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:30:31.700Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:30:31.743Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:30:31.744Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:30:40.591Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:30:40.602Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:30:40.611Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:30:40.611Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:30:40.633Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:30:42.747Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:30:42.747Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:36:03.880Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:36:03.904Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:36:03.965Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:36:03.966Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:36:03.988Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:36:03.988Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:36:04.018Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:38:21.296Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:41:07.305Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:41:07.356Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:41:07.359Z"}
{"level":"danger","message":"An error has occured: YoutTube Disconnected\nSTDERR: frame= 5474 fps= 24 q=-1.0 size= 9607kB time=00:03:48.00 bitrate= 345.2kbits/s speed=1.01x \nframe= 5486 fps= 24 q=-1.0 size= 9621kB time=00:03:48.50 bitrate= 344.9kbits/s speed=1.01x \nframe= 5498 fps= 24 q=-1.0 size= 9632kB time=00:03:49.00 bitrate= 344.6kbits/s speed=1.01x \nframe= 5510 fps= 24 q=-1.0 size= 9647kB time=00:03:49.50 bitrate= 344.4kbits/s speed=1.01x \nframe= 5523 fps= 24 q=-1.0 size= 9680kB time=00:03:50.04 bitrate= 344.7kbits/s speed=1.01x \nframe= 5534 fps= 24 q=-1.0 size= 9714kB time=00:03:50.50 bitrate= 345.2kbits/s speed=1.01x \nframe= 5545 fps= 24 q=-1.0 size= 9722kB time=00:03:50.95 bitrate= 344.8kbits/s speed=1.01x \nframe= 5558 fps= 24 q=-1.0 size= 9728kB time=00:03:51.50 bitrate= 344.2kbits/s speed=1.01x \nframe= 5570 fps= 24 q=-1.0 size= 9738kB time=00:03:52.00 bitrate= 343.9kbits/s speed=1.01x \nframe= 5582 fps= 24 q=-1.0 size= 9745kB time=00:03:52.50 bitrate= 343.4kbits/s speed=1.01x \nframe= 5582 fps= 19 q=-1.0 size= 9746kB time=00:03:52.50 bitrate= 343.4kbits/s speed=0.799x \nav_interleaved_write_frame(): Broken pipe\n[flv @ 0x5640d81ce980] Failed to update header with correct duration.\n[flv @ 0x5640d81ce980] Failed to update header with correct filesize.\nError writing trailer of rtmp://a.rtmp.youtube.com/live2/upjm-kz0g-c3wt-7zuj: Broken pipe\nframe= 5604 fps= 19 q=-1.0 Lsize= 9804kB time=00:03:53.41 bitrate= 344.1kbits/s speed=0.802x \nvideo:7808kB audio:1823kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.803781%\nConversion failed!\n\n","timestamp":"2017-07-19T17:41:07.391Z"}
{"level":"warning","message":"Trying to reconnect to: a.rtmp.youtube.com/live2/ on port 1935.","timestamp":"2017-07-19T17:41:07.392Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:41:07.406Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:41:07.516Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:41:07.530Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:41:09.429Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:41:09.429Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:41:21.546Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:41:21.571Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:41:21.632Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:41:21.633Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:41:21.661Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:41:21.662Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:41:21.698Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:42:42.965Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:43:55.471Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:43:55.520Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:43:55.521Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:43:55.552Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:44:41.975Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:44:42.000Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:44:42.062Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:44:42.063Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:44:42.115Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:44:42.169Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:44:42.169Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:45:02.050Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:45:02.076Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:45:02.116Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:45:02.117Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:45:02.144Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:45:04.163Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:45:04.163Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:45:59.807Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T17:47:57.395Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:47:57.436Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:47:57.437Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:47:57.467Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:47:59.585Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:47:59.586Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:38.408Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:52:38.439Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:52:38.522Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:38.523Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:52:38.563Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:38.635Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:38.635Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:50.421Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T17:52:50.446Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T17:52:50.502Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:50.503Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T17:52:50.565Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:50.611Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:50.611Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:52:57.816Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-07-19T17:52:57.830Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T17:52:57.830Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T17:52:59.847Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T17:52:59.847Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T17:53:47.588Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:03:02.581Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:03:02.606Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:03:02.665Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:03:02.666Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:03:02.737Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 41969","timestamp":"2017-07-19T18:03:03.782Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:03:03.783Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:03:53.770Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:04:07.117Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x561947db3540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:05:13.123Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 5546.","timestamp":"2017-07-19T18:05:13.125Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:08:07.186Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:09:53.358Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:09:53.382Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:09:53.459Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:09:53.460Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:09:53.495Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:09:53.570Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:09:53.570Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:09:58.961Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:09:58.968Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:09:58.994Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:11:37.267Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:11:37.291Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:11:37.354Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:11:37.355Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:11:37.423Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 41969","timestamp":"2017-07-19T18:11:37.467Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:11:37.467Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:11:43.512Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x564d7690f540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:13:46.829Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:13:46.830Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:13:46.959Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:13:46.964Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x5589dd82b540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:15:56.534Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:15:56.541Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:16:01.733Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:16:01.738Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x558620a74540] Connection to tcp://mpv.cdn3.bigCDN.com:5544?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:5544/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:18:11.361Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 554.","timestamp":"2017-07-19T18:18:11.362Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:18:11.541Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:18:11.545Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:19:20.521Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:19:22.990Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:19:23.015Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:19:23.125Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:19:25.936Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:19:25.937Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:19:26.054Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:19:26.054Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:21:13.532Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:21:13.564Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:21:13.648Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:21:13.649Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:21:13.676Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:21:13.677Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:21:13.713Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:21:21.525Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:21:22.960Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:21:34.106Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:22:12.365Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:22:12.389Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:22:12.455Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:22:12.456Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:22:12.479Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:22:12.480Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:22:12.521Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:22:40.864Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:26:30.618Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:26:30.642Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:26:30.747Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:26:33.750Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:26:33.751Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:26:33.867Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:26:33.868Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:26:45.741Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:26:45.766Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:26:45.834Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:26:45.835Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:26:45.891Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:26:45.945Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:26:45.945Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:28:07.342Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:28:07.366Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:28:07.439Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:28:07.440Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:28:07.478Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:28:07.550Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:28:07.550Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:28:13.009Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:30:18.057Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:30:18.082Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:30:18.144Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:30:18.145Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:30:18.220Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 37455","timestamp":"2017-07-19T18:30:19.176Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:30:19.176Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:30:25.569Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-07-19T18:30:25.584Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:30:25.609Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:31:42.833Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:31:42.860Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:31:42.924Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:31:42.925Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:31:42.993Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 37597","timestamp":"2017-07-19T18:31:44.043Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:31:44.044Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:31:50.736Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:07.290Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:32:07.314Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:32:07.378Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:32:07.380Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:32:07.439Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43737","timestamp":"2017-07-19T18:32:08.412Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:32:08.412Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:20.897Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:32:20.923Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:32:20.986Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:32:20.988Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:32:21.056Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 43737","timestamp":"2017-07-19T18:32:21.101Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:32:21.102Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:32:31.954Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T18:33:12.820Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T18:33:12.820Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:33:13.823Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:33:15.853Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:33:15.854Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x562f08fb3540] Connection to tcp://mpv.cdn3.bigCDN.com:557?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:557/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:34:30.989Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 558.","timestamp":"2017-07-19T18:34:30.991Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:14.427Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:54:14.451Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:54:14.512Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:54:14.513Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:54:14.539Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:54:14.539Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:54:14.570Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:20.445Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:54:51.852Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:54:51.876Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:54:51.944Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:54:51.945Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:54:52.005Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 39779","timestamp":"2017-07-19T18:54:52.978Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:54:52.978Z"}
{"level":"info","message":"Taking Snapshot.","timestamp":"2017-07-19T18:54:53.095Z"}
{"level":"danger","message":"Snapshot failed: TypeError: snapBuff.run is not a function","timestamp":"2017-07-19T18:54:53.097Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-07-19T18:55:16.432Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-07-19T18:55:16.432Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:55:17.433Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:55:19.464Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:55:19.464Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:56:44.869Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-07-19T18:56:44.894Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-07-19T18:56:44.956Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-07-19T18:56:44.957Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-07-19T18:56:44.982Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-07-19T18:56:44.982Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-07-19T18:56:45.011Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-07-19T18:56:55.999Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x557c64499540] Connection to tcp://mpv.cdn3.bigCDN.com:559?timeout=0 failed: Connection timed out\nrtsp://mpv.cdn3.bigCDN.com:559/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Connection timed out\n\n","timestamp":"2017-07-19T18:58:55.309Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-07-19T18:58:55.311Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:13:34.653Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:13:34.680Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:13:34.885Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x55fccbd43aa0] Failed to resolve hostname mpv.cdn3.bigCDN.com: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-03T10:13:54.930Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-08-03T10:13:54.931Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:13:57.306Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:13:57.307Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:13:57.748Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-03T10:13:57.749Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:14:32.834Z"}
{"level":"danger","message":"An (SSH) error has occured: Command failed: ssh -NR 10000:localhost:22 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=1 hiro@localhost\nstty: 'standard input': Inappropriate ioctl for device\n\u001b[91mcould not connect to remote: dial tcp [::1]:22: getsockopt: connection refused\u001b[0m\r\nssh_exchange_identification: Connection closed by remote host\r\n","timestamp":"2017-08-03T10:14:33.150Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:14:35.689Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:14:35.690Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:15:46.411Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:15:48.448Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:15:48.448Z"}
{"level":"warning","message":"Disconnected from the Master-Server.","timestamp":"2017-08-03T10:17:04.551Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:17:07.061Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:31:58.486Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:31:58.504Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:31:58.556Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:31:58.556Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:31:58.666Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:31:58.675Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:31:58.675Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x564f7c06aaa0] Failed to resolve hostname mpv.cdn3.bigCDN.com: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-03T10:32:18.735Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com on port 560.","timestamp":"2017-08-03T10:32:18.737Z"}
{"level":"warning","message":"SSH is disconnected","timestamp":"2017-08-03T10:32:19.019Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:32:19.019Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:32:21.031Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:32:21.031Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:33:30.511Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:33:30.512Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:33:31.515Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:33:33.551Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:33:33.552Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:33:38.340Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:33:38.341Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:33:40.845Z"}
{"level":"info","message":"Setting SSH ports to 10000 and 8081","timestamp":"2017-08-03T10:33:42.880Z"}
{"level":"success","message":"SSH tunnels are up and running.","timestamp":"2017-08-03T10:33:42.881Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:35:09.786Z"}
{"level":"danger","message":"An (SSH) error has occured: Connection to SSH-Manager lost!","timestamp":"2017-08-03T10:35:09.786Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:56:00.570Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:56:00.589Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-03T10:56:00.647Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-03T10:56:00.648Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:56:00.665Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-03T10:56:01.098Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-03T10:56:01.100Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-03T10:56:11.731Z"}
{"level":"info","message":"Restarting Streamx","timestamp":"2017-08-03T10:56:11.732Z"}
{"level":"info","message":"Sopping Stream","timestamp":"2017-08-03T10:56:11.734Z"}
{"level":"danger","message":"Force Stop!","timestamp":"2017-08-03T10:56:14.735Z"}
{"level":"success","message":"Stopped Stream","timestamp":"2017-08-03T10:56:14.738Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-03T10:56:14.738Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-03T10:56:14.743Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-04T09:06:43.563Z"}
{"level":"info","message":"Starting Stream","timestamp":"2017-08-04T09:06:43.589Z"}
{"level":"success","message":"Connected to the Master-Server.","timestamp":"2017-08-04T09:06:43.664Z"}
{"level":"info","message":"Attempting to create the SSH tunnels.","timestamp":"2017-08-04T09:06:43.665Z"}
{"level":"success","message":"Started Stream","timestamp":"2017-08-04T09:06:43.802Z"}
{"level":"warning","message":"Although the times are hard, we will try to reconnect the SSH tunels once the connection to the SSH-Manager is regained!","timestamp":"2017-08-04T09:06:44.110Z"}
{"level":"danger","message":"An (SSH) error has occured: Cannot connect to the SSH-Manager.","timestamp":"2017-08-04T09:06:44.112Z"}
{"level":"danger","message":"An error has occured: Camera Disconnected\nSTDERR: ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers\n built with gcc 7.1.1 (GCC) 20170516\n configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-shared --enable-version3\n libavutil 55. 58.100 / 55. 58.100\n libavcodec 57. 89.100 / 57. 89.100\n libavformat 57. 71.100 / 57. 71.100\n libavdevice 57. 6.100 / 57. 6.100\n libavfilter 6. 82.100 / 6. 82.100\n libavresample 3. 5. 0 / 3. 5. 0\n libswscale 4. 6.100 / 4. 6.100\n libswresample 2. 7.100 / 2. 7.100\n libpostproc 54. 5.100 / 54. 5.100\n[tcp @ 0x5630a5550aa0] Failed to resolve hostname mpv.cdn3.bigCDN.com1: Name or service not known\nrtsp://mpv.cdn3.bigCDN.com1:560/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4: Input/output error\n\n","timestamp":"2017-08-04T09:06:45.503Z"}
{"level":"warning","message":"Trying to reconnect to: mpv.cdn3.bigCDN.com1 on port 560.","timestamp":"2017-08-04T09:06:45.505Z"}
{"level":"info","message":"Config Updated","timestamp":"2017-08-04T09:07:27.111Z"}

View file

@ -5,9 +5,10 @@
const redux = require('redux');
const ReduxThunk = require('redux-thunk').default;
const communicator = require('./src/communicator.js');
const commander = require('./src/commander.js');
const communicator = require('./src/communicator.js');
const commander = require('./src/commander.js');
const logger = require('./src/logger.js');
const ssh = require('./src/ssh.js');
///////////////////////////////////////////////////////////////////////////////
// Redux //
@ -20,6 +21,7 @@ const logger = require('./src/logger.js');
* @property { number | bool } stream.error Error code. Any number outside the range of the Error array in @see ffmpeg-command.js will be treated as non error. Most conveniently set: false.
* @property { bool | string } stream.errorHandling Indicates wether the program tries to handle an error.
* @property { bool } stream.restaring Indicades wether the stream is currently being restarted.
* @property { bool } stream.takingSnapshot Indicades wether a Snapshot is being taken.
* @property { Object } config Configuration of the camera.
* @property { Object } ssh The SSH tunnel status.
* @property { bool } ssh.enabled
@ -30,20 +32,23 @@ const logger = require('./src/logger.js');
* @property { string } ssh.error The SSH Error, if there is any. You might check ssh.willReconnect as well, to see if a retry is sceduled as soon as the connection to the manager is regained.
*/
let initialState = {
name: 'Unnamed',
stream: {
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false
running: 'STOPPED',
error: false,
reconnecting: false,
handleError: false,
restaring: false,
snapshot: {
taking: false,
failed: false
}
},
ssh: {
status: 'DISCONNECTED', // TODO: CD
cameraForwardPort: false,
sshForwardPort: false,
willReconnect: false,
error: false
status: 'DISCONNECTED', // TODO: CD // TODO: Implement in WEBIF
cameraForwardPort: false,
sshForwardPort: false,
willReconnect: false,
error: false
},
connected: false,
config: false
@ -53,7 +58,7 @@ let initialState = {
const reducer = require('./src/reducers');
// Reference to the store of the application state.
const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk, logger.middleware, communicator.middleware));
const store = redux.createStore(reducer, initialState, redux.applyMiddleware(ReduxThunk, logger.middleware, communicator.middleware, ssh.middleware, commander.middleware));
// The dispatch function for the state.
const dispatch = store.dispatch;
@ -74,11 +79,15 @@ const creators = require('./src/actions.js').creators;
// Code the Config
dispatch(creators.updateConfig());
// Instanciate the Commander
const Commander = new commander(getState, getConfig, dispatch);
// The server Communication
const Communicator = new communicator(getState, getConfig, dispatch);
dispatch(Commander.start());
const Communicator = new communicator(getState, getConfig, dispatch, Commander);
// Start the Stream
dispatch(Commander.start()).then().catch(); // TODO: Better Handling
/**
* We're good to go from here!
*/

View file

@ -5,7 +5,7 @@
const Promise = require('promise');
const writeConfig = require('./utility/config.js').write;
const readConfig = require('./utility/config.js').read;
const readConfig = require('./utility/config.js').read;
///////////////////////////////////////////////////////////////////////////////
// Declarations //
@ -22,10 +22,12 @@ let actions = {
REQUEST_STOP: 'REQUEST_STOP',
SET_STOPPED: 'SET_STOPPED',
REQUEST_RESTART: 'REQUEST_RESTART',
TAKE_SNAPSHOT: 'TAKE_SNAPSHOT',
SET_SNAPSHOT_FAILED: 'SET_SNAPSHOT_FAILED',
SET_SNAPSHOT_TAKEN: 'SET_SNAPSHOT_TAKEN',
SET_ERROR: 'SET_ERROR',
TRY_RECONNECT: 'TRY_RECONNECT',
STOP_ERROR_HANDLING: 'STOP_ERROR_HANDLING',
SET_NAME: 'SET_NAME',
// Communicator
SET_CONNECTED: 'SET_CONNECTED',
@ -39,7 +41,7 @@ let actions = {
SET_SSH_REMOTE_PORTS: 'SET_SSH_REMOTE_PORTS',
SET_SSH_ERROR: 'SET_SSH_ERROR',
SET_SSH_WILL_RECONNECT: 'SET_SSH_WILL_RECONNECT',
// Master Server Related
HYDRATE: 'HYDRATE'
};
@ -61,27 +63,28 @@ let creators = {};
*/
creators.updateConfig = function(update) {
return (dispatch, getState) => {
let init = false;
if(!update) {
init = true;
update = readConfig();
let init = false;
if (!update) {
init = true;
update = readConfig();
// TODO: Proper handling.
if (!update)
throw new Error('Could not load config.');
}
// TODO: Proper handling.
if(!update)
throw new Error('Could not load config.');
}
dispatch({
type: actions.UPDATE_CONFIG,
data: update
});
if(update.name)
dispatch(creators.setName(update.name));
return init ? Promise.resolve() : writeConfig(getState);
// TODO: CD
if (init)
return Promise.resolve('Config Updated.');
else
return writeConfig(getState().config);
};
};
@ -115,89 +118,101 @@ creators.requestRestart = function() {
};
};
creators.takeSnapshot = function() {
return {
type: actions.TAKE_SNAPSHOT
};
};
creators.setSnapshotFailed = function(error) {
return {
type: actions.SET_SNAPSHOT_FAILED,
data: error
};
};
creators.setSnapshotTaken = function() {
return {
type: actions.SET_SNAPSHOT_TAKEN
};
};
// Optional error Message for logging.
creators.setError = function(error, stdout, stderr) {
return {
type: actions.SET_ERROR,
data: error,
stdout,
stderr
stdout,
stderr
};
};
creators.setTryReconnect = function(to) {
return {
type: actions.TRY_RECONNECT,
to
};
};
creators.setName = function(name) {
return {
type: actions.SET_NAME,
data: name
type: actions.TRY_RECONNECT,
to
};
};
creators.stopErrorHandling = function() {
return {
type: actions.STOP_ERROR_HANDLING
type: actions.STOP_ERROR_HANDLING
};
};
creators.setConnected = function() {
return {
type: actions.SET_CONNECTED
type: actions.SET_CONNECTED
};
};
creators.setDisconnected = function() {
return {
type: actions.SET_DISCONNECTED
type: actions.SET_DISCONNECTED
};
};
creators.setSSHRemotePorts = function(ports) {
return {
type: actions.SET_SSH_REMOTE_PORTS,
data: ports
type: actions.SET_SSH_REMOTE_PORTS,
data: ports
};
};
creators.setSSHConnecting = function() {
return {
type: actions.SET_SSH_CONNECTING
type: actions.SET_SSH_CONNECTING
};
};
creators.setSSHConnected = function() {
return {
type: actions.SET_SSH_CONNECTED
type: actions.SET_SSH_CONNECTED
};
};
creators.setSSHDisconnecting = function(error) {
return {
type: actions.SET_SSH_DISCONNECTING
type: actions.SET_SSH_DISCONNECTING
};
};
creators.setSSHDisconnected = function() {
return {
type: actions.SET_SSH_DISCONNECTED
type: actions.SET_SSH_DISCONNECTED
};
};
creators.setSSHError = function(error) {
return {
type: actions.SET_SSH_ERROR,
data: error
type: actions.SET_SSH_ERROR,
data: error
};
};
creators.setSSHWillReconnect = function(error) {
return {
type: actions.SET_SSH_WILL_RECONNECT
type: actions.SET_SSH_WILL_RECONNECT
};
};

View file

@ -7,6 +7,7 @@ const ffmpeg = require('fluent-ffmpeg');
const http = require('http');
const logger = require('./logger');
const errorHandling = require('./errorHandler.js');
const WMStrm = require('../lib/memWrite.js');
///////////////////////////////////////////////////////////////////////////////
// Declarations //
@ -17,12 +18,23 @@ let self = false;
/**
* The FFMPEG command.
* @member
* @member
*/
let cmd = ffmpeg({
stdoutLines: 20
});
/**
* The command to take a snapshot.
* @member
*/
let snapCmd = ffmpeg({
stdoutLines: 20
});
// Memory Buffer to hold 'em all... (The Snapshot)
let snapBuff;
// The Config, Logger and a handle for the kill timeout.
let _stopHandle = false;
@ -45,6 +57,10 @@ let dispatch;
// The function to get the config().
let config;
const {
UPDATE_CONFIG
} = require('./actions').actions;
// Action Creators
const {
requestStart,
@ -52,7 +68,10 @@ const {
requestRestart,
setStarted,
setStopped,
setError
setError,
takeSnapshot,
setSnapshotTaken,
setSnapshotFailed
} = require('./actions').creators;
///////////////////////////////////////////////////////////////////////////////
@ -77,7 +96,7 @@ class Commander {
throw new Error('Invalid getState() function.');
}
if ((typeof _getConfig) !== 'function' || !_getConfig()) {
if ((typeof _getConfig) !== 'function' || !_getConfig()) {
throw new Error('Please load a valid config().');
}
@ -92,10 +111,11 @@ class Commander {
dispatch = _dispatch;
// Create the FFMPEG-Command initially.
this.createCommand();
this.createCommands();
// Register events.
cmd.on('error', crashed);
cmd.on('end', crashed); // Can posibly be an error.
return this;
}
@ -195,7 +215,6 @@ Commander.prototype.stop = function() {
}, 3000);
}).then(() => {
clearTimeout(_stopHandle);
dispatch(setStopped());
resolve("Successfully Stopped!"); // TODO: CD
});
@ -203,19 +222,61 @@ Commander.prototype.stop = function() {
};
};
Commander.prototype.takeSnapshot = function() {
return (dispatch, getStatus) => {
if (getState().stream.snapshot.taking)
return Promise.reject('Another Snapshot is already being taken! Please wait.'); // TODO: CD
return new Promise((resolve, reject) => {
dispatch(takeSnapshot());
// TODO: Alternative Logging
// TODO: CD
// Init memstream.
try {
snapBuff = new WMStrm();
} catch (e) {
reject('An error occured while initializing the memeory stream.');
return;
}
// Reject on Error.
snapCmd.once('error', () => reject('An error occured while taking the snapshot'));
// Send data on Finish.
snapBuff.once('finnish', () => {
try {
resolve(snapBuff.memStore.toString('base64'));
} catch (e) {
reject('An error occured while reading the snapshot memory stream.');
}
});
snapBuff.run();
}).then(snap => {
{
dispatch(setSnapshotTaken());
return Promise.resolve(snap);
}
}, err => {
dispatch(setSnapshotFailed(err));
return Promise.reject(err);
});
};
};
/**
* (Re)Create the ffmpeg command and configure it.
* @param { Object } config The configuration for the stream.
* @returns { Object } The fluent-ffmpeg command object.
*/
Commander.prototype.createCommand = function() {
Commander.prototype.createCommands = function() {
// Clear inputs
cmd._inputs = [];
// TODO: Multi Protocol
source = 'rtsp://' + config().camIP + ':' + config().camPort + '/' + config().camProfile;
cmd.input(source);
source = 'rtsp://' + config().camIP + ':' + config().camPort + '/';
cmd.input(source + config().camProfile);
// Custom config if any.
if (config().customOutputOptions !== "")
@ -236,13 +297,20 @@ Commander.prototype.createCommand = function() {
.outputOptions(['-bufsize 50000k', '-tune film'])
.output('rtmp://a.rtmp.youtube.com/live2/' + config().key);
// Clear inputs.
snapCmd._inputs = [];
// Snap Profile.
/*snapCmd.input(source + config().snapProfile)
.outputFormat('mjpeg')
.frames(1)
.stream(snapBuff, {
end: true
});*/
return cmd;
};
/**
* Private
*/
/**
* Utilities
*/
@ -261,6 +329,10 @@ Commander.prototype.createCommand = function() {
function crashed(error, stdout, stderr) {
let errorCode, handler;
// We stopped...
if (getState().stream.running === 'STOPPED')
return;
// Can't connect to the Camera
if (error.message.indexOf(source) > -1) {
errorCode = 0;
@ -300,3 +372,27 @@ function crashed(error, stdout, stderr) {
if (handler)
dispatch(handler);
}
/**
* Redux Middleware
*/
Commander.middleware = store => next => action => {
let result = next(action);
// If sth. has changed, we restart.
if (self && getState().stream.running === 'RUNNING'
&& action.type === UPDATE_CONFIG) {
if (action.data.key ||
action.data.ffmpegPath ||
action.data.customOutputOptions ||
action.data.customVideoOptions ||
action.data.customAudioOptions ||
action.data.camIP ||
action.data.camPort) {
dispatch(self.restart()).catch(()=>{}); //TODO: error Handling
}
}
return result;
};

View file

@ -11,13 +11,17 @@
const socketio = require('socket.io-client');
const logger = require('./logger.js');
const sshMan = require('./ssh.js');
/*const { HYDRATE } = require('./actions').actions[C]*/
// Action Creators
const {
setConnected,
setDisconnected
setDisconnected,
updateConfig
} = require('./actions').creators;
// Actions
const {
UPDATE_CONFIG,
REQUEST_START,
@ -27,16 +31,28 @@ const {
REQUEST_RESTART,
SET_ERROR,
TRY_RECONNECT,
SET_NAME,
HYDRATE,
SET_CONNECTED,
SET_DISCONNECTED
} = require('./actions').actions;;
SET_DISCONNECTED,
SET_SSH_CONNECTED
} = require('./actions').actions;
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
// TODO: CD
// TODO: Update // OLD
// Commands
const commands = {
START_STOP: 'startStop',
SNAPSHOT: 'snap',
UPDATE_CONFIG: 'changeSettings',
RESTART: 'restart',
RESTART_SSH: 'restartSSH',
GET_LOGS: 'getLogs'
};
// Object oriented `this`.
let self = false;
@ -54,15 +70,18 @@ let getConfig;
// Dispatch function to alter the state.
let dispatch;
// SSH Management Abstraction
// SSH Management Abstraction.
let SSHMan;
// The FFMPEG commander.
let commander;
///////////////////////////////////////////////////////////////////////////////
// Code //
///////////////////////////////////////////////////////////////////////////////
class Communicator {
constructor(_getState, _getConfig, _dispatch) {
constructor(_getState, _getConfig, _dispatch, _commander) {
// singleton
if (self)
return self;
@ -71,21 +90,25 @@ class Communicator {
throw new Error('Invalid getState() function.');
}
if ((typeof _getConfig) !== 'function' || typeof _getConfig() !== 'object')
throw new Error('Invalid getConfig funtion!'); // TODO: Lookup if implemented everywhere
if (!_dispatch) {
throw new Error('Invalid dispatch() function.');
}
if ((typeof _getConfig) !== 'function' || !_getConfig())
throw new Error('Invalid getConfig funtion!'); // TODO: Lookup if implemented everywhere
if (typeof _commander !== 'object')
throw new Error('Invalid Commander Instance!');
self = this;
// define the locals
getState = _getState;
dispatch = _dispatch;
getConfig = _getConfig;
getConfig = _getConfig;
commander = _commander;
SSHMan = new sshMan(getState, getConfig, dispatch, this.getPorts);
SSHMan = new sshMan(getState, getConfig, dispatch, this.getPorts);
initSocket();
return this;
}
@ -109,47 +132,57 @@ Communicator.prototype.sendAction = function(action) {
// TODO: Filter
/*
socket.emit('action', action);
[C]*/
socket.emit('action', action);
[C]*/
let type, change, state = getState();
// All Legacy Stuff
switch (action.type) {
case SET_STARTED:
case SET_STOPPED:
type = 'startStop';
change = {
running: state.stream.running == 'RUNNING' ? 0 : 1, // TODO: CD
error: state.stream.error || -1
};
break;
case SET_STARTED:
case SET_STOPPED:
type = 'startStop';
change = {
running: state.stream.running == 'RUNNING' ? 0 : 1, // TODO: CD
error: state.stream.error || -1
};
break;
case SET_ERROR:
type = 'error';
change = {
running: 2,
error: state.stream.error
};
break;
case SET_ERROR:
type = 'error';
change = {
running: 2,
error: state.stream.error
};
break;
case UPDATE_CONFIG:
type = 'settings';
change = {
config: state.config
};
break;
case UPDATE_CONFIG:
type = 'settings';
case HYDRATE:
socket.emit('meta', {
running: state.stream.running == 'RUNNING' ? 0 : 1,
error: state.stream.error || -1,
name: state.name,
config: state.config
});
return;
change = {
config: Object.assign({}, state.config, {name: action.data.name}) //TODO: LEGACY
};
break;
default:
return;
case SET_SSH_CONNECTED:
change = {
port: state.ssh.sshForwardPort,
camForwardPort: state.ssh.camForwardPort
};
break;
case HYDRATE:
socket.emit('meta', {
running: state.stream.running == 'RUNNING' ? 0 : 1,
error: state.stream.error || -1,
name: state.name,
config: state.config,
haveSettings: true // LEGACY
});
return;
default:
return;
}
socket.emit('change', {
@ -158,6 +191,16 @@ Communicator.prototype.sendAction = function(action) {
});
};
/**
* Send some data up the wire.
* @param {Object} data
* @param {String} type The type of the data. (Check server code.)
* @param {String} to Socket ID of the receipient.
*/
Communicator.prototype.sendData = function(type, data, to){
socket.emit('data', {data, type}, to);
};
/**
* Sends a message to a command issuer on the web-interface.
* @param {String} title Title of the message.
@ -170,21 +213,29 @@ Communicator.prototype.sendMessage = function(title, type, text, to) {
return;
/*socket.emit('message', {
title,
type,
text
}, to);[C]*/
title,
type,
text
}, to);[C]*/
socket.emit('data', {
type: 'message',
data: {
title: 'Error',
type: 'error',
text: 'Could not start SSH tunnels!'
}
self.sendData('message', {
title: title,
type: type,
text: text
}, to);
};
/**
* Send a message of `type` `to` a socket.
* @param {String} to Recepient (socket id).
* @param {String} type Type of the message.
* @returns {function} A function with the paremers `to` and `type` frozen. @see sendMessage
*/
Communicator.prototype.sendMessageTo = function(type, to) {
return (title, text) => self.sendMessage(title, type, text, to);
};
/**
* Sends a snapshot to a command issuer on the web-interface.
* @param {Object} snapshot Snapshot to send.
@ -195,14 +246,14 @@ Communicator.prototype.sendSnapshot = function(snapshot, to) {
return;
socket.emit('data', {
type: 'snap', //TODO New with new software
type: 'snap', //TODO New with new software, more General way...
data: snapshot
}, to);
};
/**
* Finds two open ports at the master server.
* @returns {Promise} Resolves with the ports.
* @returns {Promise} Resolves with the ports.
*/
Communicator.prototype.getPorts = function() {
return new Promise((resolve, reject) => {
@ -256,12 +307,11 @@ function socketConnected() {
dispatch(setConnected());
dispatch(SSHMan.connect()).catch(() => {
// Todo Better Hanling
// For now we do nothing, as it will reconnect itself!
// TODO: Better Hanling
// For now we do nothing, as it will reconnect itself!
});
// Handle SSH Connection //TODO Implement - Action to set SSH. Auto Retry //TODO central DEFINITION
//ssh.connect();
// Handle SSH Connection //TODO Implement - Action to set SSH. Auto Retry // TODO: CD
self.sendAction({
type: HYDRATE,
@ -275,18 +325,45 @@ function socketConnected() {
function socketDisconnected() {
socket.disconnect();
dispatch(setDisconnected);
dispatch(setDisconnected());
// And just reconnect.
logger.log(logger.importance[2], 'Lost connection to the master server.');
initSocket();
}
/**
* Handle Commands //TODO Implement
* Handle Commands
*/
function handleCommand() {
function handleCommand(command, callback) {
// Well, this can be done nicer, lots of code dupes. // TODO: NICER, URGENT
// TODO: The same in callbacks...
let answerSuccess = self.sendMessageTo('success', command.sender),
answerError = self.sendMessageTo('error', command.sender);
switch (command.command) {
case commands.START_STOP: // OLD // TODO: renew
if (getState().stream.running === 'RUNNING')
dispatch(commander.stop()).then(msg => answerSuccess(msg)).catch(error => answerError(error));
else
dispatch(commander.start()).then(msg => answerSuccess(msg)).catch(error => answerError(error));
break;
case commands.RESTART:
dispatch(commander.restart()).then(msg => answerSuccess(msg)).catch(error => answerError(error));
break;
case commands.UPDATE_CONFIG:
dispatch(updateConfig(command.data)).then(msg => answerSuccess(msg)).catch(err => answerError(err));
break;
case commands.RESTART_SSH:
dispatch(SSHMan.restartTunnels()).then(msg => answerSuccess(msg)).catch(err => answerError(err));
break;
case commands.SNAPSHOT:
dispatch(commander.takeSnapshot()).then(snap => self.sendSnapshot(snap))
.catch(error => self.sendMessage('Snapshot Failed', 'error', error, command.sender));
break;
case commands.GET_LOGS:
logger.getLogs().then(logs => self.sendData('logs', logs, command.sender)).catch(() => answerError('Can\'t get logs.')); //TODO: CD
break;
}
}
/**

View file

@ -63,12 +63,15 @@ const actionMessageMap = {
SET_STARTED: ['success', 'Started Stream'],
REQUEST_STOP: ['info', 'Sopping Stream'],
SET_STOPPED: ['success', 'Stopped Stream'],
REQUEST_RESTART: ['info', 'Restarting Streamx'],
SET_ERROR: action => ['danger', `An error has occured: ${errors[action.data]}\n${action.stderr ? 'STDERR: ' + action.stderr + '\n' : ''}${action.stdout ? 'STDOUT: ' + action.stdout + '\n' : ''}`],
REQUEST_RESTART: ['info', 'Restarting Stream'],
TAKE_SNAPSHOT: ['info', 'Taking Snapshot.'],
SET_SNAPSHOT_FAILED: action => ['danger', `Snapshot failed: ${action.data}`],
SET_SNAPSHOT_TAKEN: ['success', 'Snapshot Taken'],
SET_ERROR: action => ['danger', `An error has occured: ${errors[action.data]}\n${action.stderr ? 'STDERR: ' + action.stderr + '\n' : ''}${action.stdout ? 'STDOUT: ' + action.stdout + '\n' : ''}`], // TODO: FILTER STDERR... STDOUT...
TRY_RECONNECT: action => ['warning', `Trying to reconnect to: ${action.to[0]} on port ${action.to[1]}.`],
SET_CONNECTED: ['success', 'Connected to the Master-Server.'],
SET_DISCONNECTED: ['warning', 'Disconnected from the Master-Server.'],
SET_SSH_REMOTE_PORTS: action => ['info', `Setting SSH ports to ${action.data}`],
SET_SSH_REMOTE_PORTS: action => ['info', `Setting SSH ports to ${action.data.sshForwardPort} and ${action.data.camForwardPort}`],
SET_SSH_CONNECTING: ['info', 'Attempting to create the SSH tunnels.'],
SET_SSH_CONNECTED: ['success', 'SSH tunnels are up and running.'],
SET_SSH_DISCONNECTED: ['warning', 'SSH is disconnected'],
@ -121,6 +124,32 @@ let logger = new(winston.Logger)({
]
});
/**
* A promise wrapper, to get the logs as a nice array.
* @returns {Promise} The logs or an error.
*/
logger.getLogs = function() {
return new Promise((resolve, reject) => {
logger.query({
limit: 100 //TODO: Dynamic setting...
}, function(err, data) {
logs = data.file;
if (err) {
reject(err);
return;
}
if (logs.length === 0)
logs = [];
resolve(logs);
return;
});
});
};
// TODO: Find out if needet
logger.importance = ['normal', 'info', 'warning', 'danger', 'success'];

View file

@ -11,10 +11,12 @@ const {
REQUEST_STOP,
SET_STOPPED,
REQUEST_RESTART,
TAKE_SNAPSHOT,
SET_SNAPSHOT_FAILED,
SET_SNAPSHOT_TAKEN,
SET_ERROR,
TRY_RECONNECT,
STOP_ERROR_HANDLING,
SET_NAME,
SET_CONNECTED,
SET_DISCONNECTED,
@ -39,6 +41,8 @@ function error(state = false, action) {
return action.data;
case SET_STARTED:
return false;
case SET_STOPPED:
return false;
default:
return state;
}
@ -94,6 +98,30 @@ function restarting(state = false, action) {
}
}
/**
* Set the snapshot flag.
*/
function snapshot(state = false, action) {
switch (action.type) {
case TAKE_SNAPSHOT:
return {
taking: true,
failed: false
};
case SET_SNAPSHOT_TAKEN:
return Object.assign({}, state, {
taking: false
});
case SET_SNAPSHOT_FAILED:
return {
taking: false,
failed: action.data
};
default:
return state;
}
}
/**
* @function stream
* @description Stream Root Reducer.
@ -103,7 +131,8 @@ reducers.stream = function(state = {}, action) {
running: running(state.running, action),
error: error(state.error, action),
handleError: handleError(state.handleError, action),
restarting: restarting(state.restarting, action)
restarting: restarting(state.restarting, action),
snapshot: snapshot(state.takingSnapshot, action)
};
};
@ -120,19 +149,6 @@ reducers.config = function(state = false, action) {
}
};
/**
* @function name
* @description Set the name state.
*/
reducers.name = function(state = 'Unnamed', action) {
switch (action.type) {
case SET_NAME:
return action.data;
default:
return state;
}
};
reducers.connected = function(state = false, action) {
switch (action.type) {
case SET_CONNECTED:
@ -144,45 +160,47 @@ reducers.connected = function(state = false, action) {
};
};
reducers.ssh = function(state = {enabled: false}, action){
reducers.ssh = function(state = {
enabled: false
}, action) {
switch (action.type) {
case SET_SSH_REMOTE_PORTS:
return Object.assign({}, state, {
camForwardPort: action.camForwardPort,
sshForwardport: action.sshForwardPort
});
case SET_SSH_CONNECTING:
return Object.assign({}, state, {
status: 'CONNECTING',
error: false,
willReconnect: false
});
case SET_SSH_CONNECTED:
return Object.assign({}, state, {
status: 'CONNECTED',
willReconnect: false
});
case SET_SSH_DISCONNECTED:
return Object.assign({}, state, {
status: 'DISCONNECTED',
willReconnect: false
});
case SET_SSH_DISCONNECTING:
return Object.assign({}, state, {
status: 'DISCONNECTING',
willReconnect: false
});
case SET_SSH_ERROR:
return Object.assignx({}, state, {
status: 'DISCONNECTED',
error: action.data // TODO: Checks
});
case SET_SSH_WILL_RECONNECT:
return Object.assign({}, state, {
status: 'DISCONNECTED',
willReconnect: true
});
default:
case SET_SSH_REMOTE_PORTS:
return Object.assign({}, state, {
camForwardPort: action.camForwardPort,
sshForwardport: action.sshForwardPort
});
case SET_SSH_CONNECTING:
return Object.assign({}, state, {
status: 'CONNECTING',
error: false,
willReconnect: false
});
case SET_SSH_CONNECTED:
return Object.assign({}, state, {
status: 'CONNECTED',
willReconnect: false
});
case SET_SSH_DISCONNECTED:
return Object.assign({}, state, {
status: 'DISCONNECTED',
willReconnect: false
});
case SET_SSH_DISCONNECTING:
return Object.assign({}, state, {
status: 'DISCONNECTING',
willReconnect: false
});
case SET_SSH_ERROR:
return Object.assign({}, state, {
status: 'DISCONNECTED',
error: action.data // TODO: Checks
});
case SET_SSH_WILL_RECONNECT:
return Object.assign({}, state, {
status: 'DISCONNECTED',
willReconnect: true
});
default:
return state;
};
};

View file

@ -17,6 +17,10 @@ const {
setSSHRemotePorts
} = require('./actions').creators;
const {
UPDATE_CONFIG
} = require('./actions').actions;
///////////////////////////////////////////////////////////////////////////////
// Declarations //
///////////////////////////////////////////////////////////////////////////////
@ -58,7 +62,7 @@ let getPorts;
* @param {} _getConfig
* @param {} _dispatch
* @param {} _getPorts @see `let getPorts`
* @throws {}
* @throws {}
*/
class SSHMan {
constructor(_getState, _getConfig, _dispatch, _getPorts) {
@ -88,8 +92,8 @@ class SSHMan {
getPorts = _getPorts;
dispatch = _dispatch;
self = this;
self = this;
connectIpc();
}
};
@ -107,8 +111,8 @@ SSHMan.prototype.connect = function() {
if (!getConfig().ssh)
return Promise.reject("SSH is disabled."); // TODO: CD
if (getState().ssh.status == 'CONNECTED')
return Promise.resolve();
if (getState().ssh.status == 'CONNECTED')
return Promise.resolve();
if (getState().ssh.status == 'CONNECTING')
return Promise.reject('A command which is currently being executed is in conflict with the current one.');
@ -117,12 +121,13 @@ SSHMan.prototype.connect = function() {
dispatch(setSSHConnecting());
let config = getState().config;
let newPorts = {}, ports = {};
let newPorts = {},
ports = {};
return isIpcConnected()
.then(() => getPorts())
.then((_ports) => {
if (typeof _ports.sshForwardPort !== 'number' || typeof _ports.camForwardPort !== 'number') {
return Promise.reject("Invalid Ports!");
.then(() => getPorts())
.then((_ports) => {
if (typeof _ports.sshForwardPort !== 'number' || typeof _ports.camForwardPort !== 'number') {
return Promise.reject("Invalid Ports!");
} else {
ports = _ports;
return isIpcConnected();
@ -133,9 +138,10 @@ SSHMan.prototype.connect = function() {
.then(() => createTunnel(config.camPort, ports.camForwardPort))
.then(port => newPorts.camForwardPort = port)
.then(() => isIpcConnected)
.then(() => {
.then(() => {
dispatch(setSSHRemotePorts(newPorts));
dispatch(setSSHConnected());
return Promise.resolve('SSH Tunnels successfully connected.'); // TODO: CD
})
.catch(error => {
dispatch(setSSHError(error));
@ -160,35 +166,32 @@ SSHMan.prototype.disconnect = function() {
// Let's go ahead.
dispatch(setSSHDisconnecting());
let config = getState().config();
return isIpcConnected
.then(() => closeTunnel(config.sshPort))
.then(() => closeTunnel(config.camPort))
.then(() => {
dispatch(setSSHDisconnected());
return Promise.resolve();
})
.catch((error) => {
// This means that the tunnel is not connected anymore.
dispatch(setSSHDisconnected());
let config = getState().config;
return isIpcConnected()
.then(() => closeTunnel(config.sshPort))
.then(() => closeTunnel(config.camPort))
.then(() => {
dispatch(setSSHDisconnected());
return Promise.resolve();
})
.catch((error) => {
// This means that the tunnel is not connected anymore.
dispatch(setSSHDisconnected());
return Promise.reject(error);
});
};
};
// TODO: Maybe both tunnels handled completely different.
// TODO: Maybe both tunnels handled completely independent.
/**
* An action creator that restarts the SSH Tunnels.
* @returns { Promise }
* @returns { Promise }
*/
SSHMan.prototype.restartTunnels = function() {
return (dispatch, getState) => {
let connect = () => dispatch(self.connect);
dispatch(self.disconnect())
.then(connect, connect)
.then(() => Promise.resolve("SSH Tunnels successfully restarted."))
.catch(error => Promise.reject(error)); //Todo CD
// TODO: CD
return dispatch(self.disconnect())
.then(() => dispatch(self.connect()));
};
};
@ -213,7 +216,9 @@ function connectIpc(ports) {
function ipcConnected() {
connected = true;
if (getState().ssh.willReconnect) {
dispatch(self.connect());
dispatch(self.connect()).catch(() => {
// We do nothing...
});
}
}
@ -221,12 +226,11 @@ function ipcConnected() {
* Handler for the IPC Disconnect Event.
*/
function ipcDisconnected() {
if(!connected)
return;
if (!connected)
return;
connected = false;
console.log("here");
// Automatically attempt to reconnect once connection is made.
dispatch(setSSHWillReconnect());
dispatch(setSSHError("Connection to SSH-Manager lost!")); // TODO: CD
@ -238,7 +242,7 @@ function ipcDisconnected() {
* Creates a tunnel by reqesting it from the manager.
* @param { number } localPort
* @param { number } remotePort
* @returns { Promise }
* @returns { function } Action / Promise
*/
function createTunnel(localPort, remotePort) {
return new Promise((resolve, reject) => {
@ -247,7 +251,7 @@ function createTunnel(localPort, remotePort) {
let connectTimeout = setTimeout(() => reject("IPC Timeout. Can't reach SSH-Manager."), 2000); // TODO: CD
// TODO: Variable CD
// TODO: Variable CD
ipc.of.sshMan.once('success' + id, (port) => {
resolve(port); // TODO: That's ok for now, but should be auto-determined by the SSH-Manager further down the road...
});
@ -262,19 +266,26 @@ function createTunnel(localPort, remotePort) {
reject(error);
});
ipc.of.sshMan.emit('create_tunnel', {
ipc.of.sshMan.emit('create_tunnel', {
id: id,
host: config.sshMaster,
username: config.sshUser,
sshPort: config.sshPort,
localPort: localPort,
remotePort: remotePort,
sshKey: config.sshKey,
serverAliveInterval: 30,
reverse: true
});
});
}
/**
* Closes the SSH-Tunnel on the port.
* @param {number} port
* @returns {fuction} Action / Promise
*/
function closeTunnel(port) {
return new Promise((resolve, reject) => {
let id = (new Date()).getTime();
@ -297,14 +308,14 @@ function closeTunnel(port) {
ipc.of.sshMan.emit('close_tunnel', {
id: id,
port
port
});
});
}
/**
* Helper to tell if the IPC connection works.
* @returns {Promise}
* @returns {Promise}
*/
function isIpcConnected() {
if (connected)
@ -312,12 +323,35 @@ function isIpcConnected() {
// Wait a bit and try again.
return new Promise((resolve, reject) => {
ipc.of.sshMan.on('connect', () => resolve());
ipc.of.sshMan.once('error', () => {
console.log("here");
dispatch(setSSHWillReconnect());
reject('Cannot connect to the SSH-Manager.');
});
ipc.of.sshMan.on('connect', () => resolve());
ipc.of.sshMan.once('error', () => {
dispatch(setSSHWillReconnect());
reject('Cannot connect to the SSH-Manager.');
});
});
}
/**
* Redux Middleware
* Try to reconnect upon config change.
*/
SSHMan.middleware = store => next => action => {
let result = next(action); // Let it pass...
if (!self)
return true;
// If sth. has changed, we restart.
if (action.type === UPDATE_CONFIG) {
if (action.data.ssh ||
action.data.sshPort ||
action.data.sshMaster ||
action.data.sshLocalUser ||
action.data.camIP ||
action.data.camPanelPort) {
dispatch(self.restartTunnels());
}
}
return result;
}

View file

@ -1,42 +0,0 @@
/** Config read/write utilities.
* @module Utilities/Config
*/
const Promise = require('promise');
const fs = require('fs');
const logger = require('../logger.js');
// TODO: Config path in defs
module.exports = {};
// TODO Default CFG
/**
* Read the JSON config file.
* @returns { Object | bool } Returns the parsed config or false in case of anb error.
*/
module.exports.read = function() {
try {
return JSON.parse(fs.readFileSync(__dirname + '/../../config.js')); //TODO: Nicer
} catch (e) {
return false; //TODO: Log that.
}
};
/**
* Writes the config to disk.
* @param {Object} state A function to retrieve the current state. This makes it harder to accidentially write arbitrary code.
* @returns { Promise } A promise for writing the configuration.
*/
module.exports.write = function( getState ){
return new Promise((resolve, reject) => {
fs.writeFile(__dirname + '/config.js',
JSON.stringify(getState().config, undefined, 2),
err => {
if(err)
reject(err);
else
resolve();
});
});
};

4
todo
View file

@ -8,3 +8,7 @@
Host localhost
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
- Config allways
- ssh allways

1
xargs
View file

@ -1 +0,0 @@
grep: chromium: No such file or directory