Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.channel_sub = function(conn, instance, channel_obj) {
var split = channel_obj.toString().split(':');
var channel_raw = split[split.length-1];
var channel_name = 'stats.' + channel_raw;
console.log("init channel: " + channel_name);
var view = {
name: channel_raw,
label: channel_name
};
conn.write(JSON.stringify({"channel": channel_raw, "command": "init", "html": Mu.to_html(canvas_template, view)}));
if(cache[channel_raw] == undefined)
cache[channel_raw] = new Array();
if(subscriptions[channel_name] == undefined) {
subscriptions[channel_name] = new Array();
redis.subscribe(channel_name, function(msg) {
exports.route_msg(instance, channel_raw, msg);
});
}
subscriptions[channel_name].push(conn);
return channel_raw;
};
} else {
var auth = exports.decodeBase64(request.headers['authorization']);
if (!auth || !auth.username || auth.password != tempo_password) {
response.writeHead(401, {'WWW-Authenticate': 'Basic realm="Secure Area"'});
response.end();
return;
}
}
var instance = request.url.substring(1, request.url.length);
var view = {
ws_host: websocket_host,
ws_port: websocket_port,
instance: instance
};
response.writeHead(200, {'Content-Type': 'text/html'});
response.end(Mu.to_html(index_template, view));
} else {
response.writeHead(404, {'Content-Type': 'text/html'});
response.end('Not Found\n');
}
}).listen(http_port, "0.0.0.0");
to_html: function to_html(template, view, partials, send) {
if (!view)
view = {};
return translate(orig_mustache.to_html(template, view, partials, send));
},
clearCache: function clearCache() {