From 5bd7e19ddda00fd79e4b386ea3d1afc4ffeb6e40 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 8 Jun 2017 14:02:06 +0200 Subject: [PATCH] guard against invalid channels, make session expiration time configurable --- rpc.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpc.js b/rpc.js index fa61d19d4..7057028e2 100644 --- a/rpc.js +++ b/rpc.js @@ -16,9 +16,10 @@ var RPC = module.exports; var Store = require("./storage/file"); var DEFAULT_LIMIT = 50 * 1024 * 1024; +var SESSION_EXPIRATION_TIME = 60 * 1000; var isValidId = function (chan) { - return /^[a-fA-F0-9]/.test(chan) || + return chan && chan.length && /^[a-fA-F0-9]/.test(chan) || [32, 48].indexOf(chan.length) !== -1; }; @@ -1058,7 +1059,7 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function) // expire old sessions once per minute setInterval(function () { expireSessions(Sessions); - }, 60000); + }, SESSION_EXPIRATION_TIME); }); }); });