Merge branch '3.0' into web-refactoring
This commit is contained in:
commit
5ead24e45e
|
@ -1,5 +1,8 @@
|
|||
var Logger = require('./logger');
|
||||
var counterLog = new Logger.Logger('counters.log');
|
||||
import os from 'os';
|
||||
import io from 'socket.io';
|
||||
import Socket from 'socket.io/lib/socket';
|
||||
|
||||
var counters = {};
|
||||
|
||||
|
@ -15,7 +18,20 @@ exports.add = function (counter, value) {
|
|||
}
|
||||
};
|
||||
|
||||
Socket.prototype._packet = Socket.prototype.packet;
|
||||
Socket.prototype.packet = function () {
|
||||
this._packet.apply(this, arguments);
|
||||
exports.add('socket.io:packet');
|
||||
};
|
||||
|
||||
setInterval(function () {
|
||||
counterLog.log(JSON.stringify(counters));
|
||||
try {
|
||||
counters['memory:rss'] = process.memoryUsage().rss / 1048576;
|
||||
counters['load:1min'] = os.loadavg()[0];
|
||||
counters['socket.io:count'] = io.instance.sockets.sockets.length;
|
||||
counterLog.log(JSON.stringify(counters));
|
||||
} catch (e) {
|
||||
Logger.errlog.log(e.stack);
|
||||
}
|
||||
counters = {};
|
||||
}, 60000);
|
||||
|
|
|
@ -14,6 +14,7 @@ var util = require("../utilities");
|
|||
var crypto = require("crypto");
|
||||
var isTorExit = require("../tor").isTorExit;
|
||||
var session = require("../session");
|
||||
import counters from '../counters';
|
||||
|
||||
var CONNECT_RATE = {
|
||||
burst: 5,
|
||||
|
@ -77,6 +78,7 @@ function ipLimitReached(sock) {
|
|||
var ip = sock._realip;
|
||||
|
||||
sock.on("disconnect", function () {
|
||||
counters.add("socket.io:disconnect", 1);
|
||||
ipCount[ip]--;
|
||||
if (ipCount[ip] === 0) {
|
||||
/* Clear out unnecessary counters to save memory */
|
||||
|
@ -169,6 +171,7 @@ function handleConnection(sock) {
|
|||
}
|
||||
|
||||
Logger.syslog.log("Accepted socket from " + ip);
|
||||
counters.add("socket.io:accept", 1);
|
||||
|
||||
addTypecheckedFunctions(sock);
|
||||
|
||||
|
@ -225,7 +228,6 @@ module.exports = {
|
|||
} else {
|
||||
var server = require("http").createServer().listen(bind.port, bind.ip);
|
||||
server.on("clientError", function (err, socket) {
|
||||
console.error("clientError on " + id + " - " + err);
|
||||
try {
|
||||
socket.destroy();
|
||||
} catch (e) {
|
||||
|
|
|
@ -110,7 +110,6 @@ var Server = function () {
|
|||
self.servers[id] = https.createServer(opts, self.express)
|
||||
.listen(bind.port, bind.ip);
|
||||
self.servers[id].on("clientError", function (err, socket) {
|
||||
console.error("clientError on " + id + " - " + err);
|
||||
try {
|
||||
socket.destroy();
|
||||
} catch (e) {
|
||||
|
@ -119,7 +118,6 @@ var Server = function () {
|
|||
} else if (bind.http) {
|
||||
self.servers[id] = self.express.listen(bind.port, bind.ip);
|
||||
self.servers[id].on("clientError", function (err, socket) {
|
||||
console.error("clientError on " + id + " - " + err);
|
||||
try {
|
||||
socket.destroy();
|
||||
} catch (e) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import morgan from 'morgan';
|
|||
import csrf from './csrf';
|
||||
import * as HTTPStatus from './httpstatus';
|
||||
import { CSRFError, HTTPError } from '../errors';
|
||||
import counters from "../counters";
|
||||
|
||||
function initializeLog(app) {
|
||||
const logFormat = ':real-address - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"';
|
||||
|
@ -141,6 +142,11 @@ module.exports = {
|
|||
* Initializes webserver callbacks
|
||||
*/
|
||||
init: function (app, webConfig, ioConfig, clusterClient, channelIndex, session) {
|
||||
app.use((req, res, next) => {
|
||||
counters.add("http:request", 1);
|
||||
req._ip = ipForRequest(req);
|
||||
next();
|
||||
});
|
||||
require('./middleware/x-forwarded-for')(app, webConfig);
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: false,
|
||||
|
|
|
@ -49,9 +49,6 @@ mixin us-general
|
|||
p.text-danger Changing layouts may require refreshing to take effect.
|
||||
mixin rcheckbox("us-no-channelcss", "Ignore Channel CSS")
|
||||
mixin rcheckbox("us-no-channeljs", "Ignore Channel Javascript")
|
||||
.col-sm-4
|
||||
.col-sm-8
|
||||
p#us-conninfo.text-info <strong>Connection Information: </strong>
|
||||
.clear
|
||||
|
||||
mixin us-scripts
|
||||
|
|
|
@ -1138,7 +1138,6 @@ setupCallbacks = function() {
|
|||
}
|
||||
|
||||
var opts = {
|
||||
transports: ["websocket", "polling"],
|
||||
secure: chosenServer.secure
|
||||
};
|
||||
|
||||
|
|
|
@ -624,23 +624,6 @@ function showUserOptions() {
|
|||
$("#us-layout").val(USEROPTS.layout);
|
||||
$("#us-no-channelcss").prop("checked", USEROPTS.ignore_channelcss);
|
||||
$("#us-no-channeljs").prop("checked", USEROPTS.ignore_channeljs);
|
||||
var conninfo = "<strong>Connection Information: </strong>" +
|
||||
"Connected to <code>" + IO_URL + "</code> (";
|
||||
if (IO_V6) {
|
||||
conninfo += "IPv6, ";
|
||||
} else {
|
||||
conninfo += "IPv4, ";
|
||||
}
|
||||
|
||||
if (IO_URL === IO_URLS["ipv4-ssl"] || IO_URL === IO_URLS["ipv6-ssl"]) {
|
||||
conninfo += "SSL)";
|
||||
} else {
|
||||
conninfo += "no SSL)";
|
||||
}
|
||||
|
||||
conninfo += ". SSL is enabled by default if it is supported by the server.";
|
||||
$("#us-conninfo").html(conninfo);
|
||||
|
||||
|
||||
$("#us-synch").prop("checked", USEROPTS.synch);
|
||||
$("#us-synch-accuracy").val(USEROPTS.sync_accuracy);
|
||||
|
|
Loading…
Reference in a new issue