Improved web relay sharing (#4413)
This commit is contained in:
parent
5d7fabfc21
commit
4fe394226c
11
apprelays.js
11
apprelays.js
|
@ -92,7 +92,12 @@ module.exports.CreateWebRelaySession = function (parent, db, req, args, domain,
|
|||
obj.webCookies = {};
|
||||
|
||||
// Setup an expire time if needed
|
||||
if (expire != null) { var timeout = (expire - Date.now()); if (timeout < 10) { timeout = 10; } obj.expireTimer = setTimeout(close, timeout); }
|
||||
if (expire != null) {
|
||||
var timeout = (expire - Date.now());
|
||||
if (timeout < 10) { timeout = 10; }
|
||||
parent.parent.debug('webrelay', 'timeout set to ' + Math.floor(timeout / 1000) + ' second(s).');
|
||||
obj.expireTimer = setTimeout(function () { parent.parent.debug('webrelay', 'timeout'); close(); }, timeout);
|
||||
}
|
||||
|
||||
// Events
|
||||
obj.closed = false;
|
||||
|
@ -131,6 +136,8 @@ module.exports.CreateWebRelaySession = function (parent, db, req, args, domain,
|
|||
|
||||
// Handle request
|
||||
function handleNextRequest() {
|
||||
if (obj.closed == true) return;
|
||||
|
||||
// if there are not pending requests, do nothing
|
||||
if (pendingRequests.length == 0) return;
|
||||
|
||||
|
@ -155,6 +162,7 @@ module.exports.CreateWebRelaySession = function (parent, db, req, args, domain,
|
|||
|
||||
function launchNewTunnel() {
|
||||
// Launch a new tunnel
|
||||
if (obj.closed == true) return;
|
||||
parent.parent.debug('webrelay', 'launchNewTunnel');
|
||||
const tunnel = module.exports.CreateWebRelay(obj, db, args, domain);
|
||||
tunnel.onclose = function (tunnelId, processedCount) {
|
||||
|
@ -188,6 +196,7 @@ module.exports.CreateWebRelaySession = function (parent, db, req, args, domain,
|
|||
}
|
||||
}
|
||||
tunnel.onNextRequest = function () {
|
||||
if (tunnels == null) return;
|
||||
parent.parent.debug('webrelay', 'tunnel-onNextRequest');
|
||||
handleNextRequest();
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ module.exports.CreateWebRelayServer = function (parent, db, args, certificates,
|
|||
if (req.session.userid) { delete req.session.userid; } // Clear the web relay userid
|
||||
if (req.session.z != webSessionId) { req.session.z = webSessionId; } // Set the web relay guest session
|
||||
expire = urlCookie.expire;
|
||||
if ((expire != null) && (expire <= Date.now())) { parent.debug('webrelay', 'expired link'); res.sendStatus(404); return; }
|
||||
}
|
||||
|
||||
// No session identifier was setup, exit now
|
||||
|
@ -246,7 +247,7 @@ module.exports.CreateWebRelayServer = function (parent, db, args, certificates,
|
|||
if (xrelaySession != null) { xrelaySession.close(); delete relaySessions[webSessionId]; }
|
||||
|
||||
// Create a web relay session
|
||||
const relaySession = require('./apprelays.js').CreateWebRelaySession(obj, db, req, args, domain, userid, nodeid, addr, port, appid, xrelaySession, expire);
|
||||
const relaySession = require('./apprelays.js').CreateWebRelaySession(obj, db, req, args, domain, userid, nodeid, addr, port, appid, webSessionId, expire);
|
||||
relaySession.onclose = function (sessionId) {
|
||||
// Remove the relay session
|
||||
delete relaySessions[sessionId];
|
||||
|
|
|
@ -6610,6 +6610,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
|||
if (req.session.userid) { delete req.session.userid; } // Clear the web relay userid
|
||||
if (req.session.z != webSessionId) { req.session.z = webSessionId; } // Set the web relay guest session
|
||||
expire = urlCookie.expire;
|
||||
if ((expire != null) && (expire <= Date.now())) { parent.debug('webrelay', 'expired link'); res.sendStatus(404); return; }
|
||||
}
|
||||
|
||||
// No session identifier was setup, exit now
|
||||
|
|
Loading…
Reference in New Issue