Improved HTTP sharing domains.

Ylian Saint-Hilaire committed Jan 4, 2021 at 03:14 UTC aba5de4e0d902c8c0b31f091ea9bcc4e47206407
3 files changed +11 -23
agents/agent-translations.json
+2 -1
@@ -296,7 +296,8 @@
296 "NIET ACTIEF"
297 ],
298 "statusDescription": "Huidige agent status",
299 - "description": "Klik op de onderstaande knoppen om de mesh-agent te installeren of te verwijderen. Na installatie wordt deze software op de achtergrond uitgevoerd, zodat deze computer kan worden beheerd en bestuurd door een externe beheerder."
299 + "description": "Klik op de onderstaande knoppen om de mesh-agent te installeren of te verwijderen. Na installatie wordt deze software op de achtergrond uitgevoerd, zodat deze computer kan worden beheerd en bestuurd door een externe beheerder.",
300 + "graphicalerror": "De grafische versie van dit installatieprogramma kan niet op dit systeem worden uitgevoerd"
301 },
302 "pt": {
303 "agent": "Agente",
translate/translate.json
+1 -1
@@ -45836,4 +45836,4 @@
45836 ]
45837 }
45838 ]
45839 -}
45839 +}
\ No newline at end of file
webserver.js
+8 -21
@@ -5003,26 +5003,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5003 // Extend the session time by forcing a change to the session every minute.
5004 if (req.session.userid != null) { req.session.nowInMinutes = Math.floor(Date.now() / 60e3); } else { delete req.session.nowInMinutes; }
5005
5006 - // Detect if this is a file sharing domain, if so, just share files.
5007 - if ((domain != null) && (domain.share != null)) {
5008 - var rpath;
5009 - if (domain.dns == null) { rpath = req.url.split('/'); rpath.splice(1, 1); rpath = rpath.join('/'); } else { rpath = req.url; }
5010 - if ((req.headers != null) && (req.headers.upgrade)) {
5011 - // If this is a websocket, stop here.
5012 - res.sendStatus(404);
5013 - } else {
5014 - // Check if the file exists, if so, serve it.
5015 - var fpath = obj.path.join(domain.share, rpath);
5016 - if (rpath == '') {
5017 - res.redirect(req.url + '/' + getQueryPortion(req));
5018 - } else {
5019 - obj.fs.exists(fpath, function (exists) { if (exists == true) { res.sendFile(rpath, { root: domain.share }); } else { next(); } });
5020 - }
5021 - }
5022 - } else {
5023 - //if (parent.config.settings.accesscontrolalloworigin != null) { headers['Access-Control-Allow-Origin'] = parent.config.settings.accesscontrolalloworigin; }
5024 - return next();
5025 - }
5006 + // Continue processing the request
5007 + return next();
5008 });
5009
5010 if (obj.agentapp) {
@@ -5058,10 +5040,15 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5040 });
5041 }
5042
5043 + // Setup all sharing domains
5044 + for (var i in parent.config.domains) {
5045 + if ((parent.config.domains[i].dns == null) && (parent.config.domains[i].share != null)) { obj.app.use(parent.config.domains[i].url, obj.express.static(parent.config.domains[i].share)); }
5046 + }
5047 +
5048 // Setup all HTTP handlers
5049 if (parent.multiServer != null) { obj.app.ws('/meshserver.ashx', function (ws, req) { parent.multiServer.CreatePeerInServer(parent.multiServer, ws, req, obj.args.tlsoffload == null); }); }
5050 for (var i in parent.config.domains) {
5064 - if (parent.config.domains[i].dns != null) { continue; } // This is a subdomain with a DNS name, no added HTTP bindings needed.
5051 + if ((parent.config.domains[i].dns != null) || (parent.config.domains[i].share != null)) { continue; } // This is a subdomain with a DNS name, no added HTTP bindings needed.
5052 var domain = parent.config.domains[i];
5053 var url = domain.url;
5054 if (domain.rootredirect == null) {