From 32fe6730e25fee26176ac836dd8cff2885d2069b Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Wed, 8 Feb 2017 20:44:39 -0800 Subject: [PATCH 01/11] Fixing BaseUrl for socket.io --- Plugins/Vorlon/vorlon.clientMessenger.ts | 10 +++++++--- Server/Scripts/vorlon.server.ts | 4 ++-- Server/config.json | 4 ++-- Server/config/vorlon.baseurlconfig.ts | 4 ++-- Server/public/vorlon.dashboardManager.ts | 5 +++++ gulpfile.js | 6 +++--- package.json | 2 +- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Plugins/Vorlon/vorlon.clientMessenger.ts b/Plugins/Vorlon/vorlon.clientMessenger.ts index 22ea19b4..89e469c3 100644 --- a/Plugins/Vorlon/vorlon.clientMessenger.ts +++ b/Plugins/Vorlon/vorlon.clientMessenger.ts @@ -53,19 +53,23 @@ Core._listenClientId = listenClientId; this._serverUrl = serverUrl; + var options = { + "path": serverUrl.split(window.location.protocol + "/")[0] + "/socket.io" + } + switch (side) { case RuntimeSide.Client: - this._socket = io.connect(serverUrl); + this._socket = io.connect(serverUrl, options); this._isConnected = true; break; case RuntimeSide.Dashboard: - this._socket = io.connect(serverUrl + "/dashboard"); + this._socket = io.connect(serverUrl + "/dashboard", options); this._isConnected = true; break; } if (this.isConnected) { - var manager = io.Manager(serverUrl); + var manager = io.Manager(serverUrl, options); manager.on('connect_error',(err) => { if (this.onError) { this.onError(err); diff --git a/Server/Scripts/vorlon.server.ts b/Server/Scripts/vorlon.server.ts index 93664ff8..38a262f0 100644 --- a/Server/Scripts/vorlon.server.ts +++ b/Server/Scripts/vorlon.server.ts @@ -296,7 +296,7 @@ export module VORLON { public start(httpServer: http.Server): void { //SOCKET.IO - var io = socketio(httpServer); + var io = socketio(httpServer, { path: this.baseURLConfig.baseURL + "/socket.io" }); this._io = io; //Listen on / @@ -306,7 +306,7 @@ export module VORLON { //Listen on /dashboard var dashboardio = io - .of("/dashboard") + .of(this.baseURLConfig.baseURL + "/dashboard") .on("connection", socket => { this.addDashboard(socket); }); diff --git a/Server/config.json b/Server/config.json index ac162a12..ed2e465b 100644 --- a/Server/config.json +++ b/Server/config.json @@ -7,11 +7,11 @@ "activateAuth": false, "username": "", "password": "", - "host": "localhost", + "host": "0.0.0.0", "port": 1337, "enableWebproxy": true, "baseProxyURL": "", - "proxyHost": "localhost", + "proxyHost": "0.0.0.0", "proxyPort": 5050, "proxyEnvPort": false, "vorlonServerURL": "", diff --git a/Server/config/vorlon.baseurlconfig.ts b/Server/config/vorlon.baseurlconfig.ts index 6ff2f27e..69eb0dcf 100644 --- a/Server/config/vorlon.baseurlconfig.ts +++ b/Server/config/vorlon.baseurlconfig.ts @@ -13,14 +13,14 @@ export module VORLON { var catalogstring = catalogdata.toString().replace(/^\uFEFF/, ''); var catalog = JSON.parse(catalogstring); if (catalog.baseURL != undefined) { - this.baseURL = catalog.baseURL; + this.baseURL = process.env.BASE_URL || catalog.baseURL; } else { this.baseURL = ""; } if (catalog.baseProxyURL != undefined) { - this.baseProxyURL = catalog.baseProxyURL; + this.baseProxyURL = process.env.BASE_PROXY_URL || catalog.baseProxyURL; } else { this.baseProxyURL = ""; diff --git a/Server/public/vorlon.dashboardManager.ts b/Server/public/vorlon.dashboardManager.ts index 2476f9c6..7bf343bf 100644 --- a/Server/public/vorlon.dashboardManager.ts +++ b/Server/public/vorlon.dashboardManager.ts @@ -30,6 +30,11 @@ module VORLON { public static StartListeningServer(clientid: string = ""): void{ var getUrl = window.location; var baseUrl = getUrl.protocol + "//" + getUrl.host; + + if(this.vorlonBaseURL) { + baseUrl = this.vorlonBaseURL.split('//')[0] === getUrl.protocol ? this.vorlonBaseURL : baseUrl + this.vorlonBaseURL; + } + VORLON.Core.StopListening(); VORLON.Core.StartDashboardSide(baseUrl, DashboardManager.SessionId, clientid, DashboardManager.divMapper); if(!VORLON.Core.Messenger.onAddClient && !VORLON.Core.Messenger.onAddClient){ diff --git a/gulpfile.js b/gulpfile.js index fc3b4f46..f7dc7006 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -320,7 +320,7 @@ gulp.task('webserver', function() { gulp.task('typescript-to-js-server', function() { var tsResult = gulp.src(['./Server/**/*.ts', '!./Server/node_modules', '!./Server/node_modules/**'], { base: './' }) - .pipe(sourcemaps.init()) + // .pipe(sourcemaps.init()) .pipe(typescript({ noExternalResolve: true, target: 'ES5', module: 'commonjs' })); return tsResult.js @@ -328,8 +328,8 @@ gulp.task('typescript-to-js-server', function() { includeContent: false, // Return relative source map root directories per file. sourceRoot: function (file) { - var sourceFile = path.join(file.cwd, file.sourceMap.file); - return path.relative(path.dirname(sourceFile), file.cwd); + // var sourceFile = path.join(file.cwd, file.sourceMap.file); + // return path.relative(path.dirname(sourceFile), file.cwd); } })) .pipe(gulp.dest('.')); diff --git a/package.json b/package.json index c3714aa0..c780751b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vorlon", - "version": "0.5.0", + "version": "0.5.3", "description": "vorlon", "main": "Server/server.js", "dependencies": { From 7871e0319ba65c456fcd53136d088013d418c9e3 Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Fri, 10 Feb 2017 16:12:16 -0800 Subject: [PATCH 02/11] Fixing VS Code launch.json --- .vscode/launch.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3bddf9dd..850e1972 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,6 +7,7 @@ // Name of configuration; appears in the launch configuration drop down menu. "name": "Launch Server/server.js", // Type of configuration. Possible values: "node", "mono". + "request": "launch", "type": "node", // Workspace relative or absolute path to the program. "program": "${workspaceRoot}/Server/server.js", @@ -29,19 +30,11 @@ // If JavaScript source maps are enabled, the generated code is expected in this directory. "outDir": null }, - { - "name": "Attach", - "type": "node", - // TCP/IP address. Default is "localhost". - "address": "localhost", - // Port to attach to. - "port": 5858, - "sourceMaps": false - }, { // not working since latest vs code and electron versions :-( "name": "Launch desktop App", "type": "node", + "request": "launch", "program": "${workspaceRoot}/desktop/app/background.js", "stopOnEntry": false, "args": [ @@ -54,6 +47,7 @@ { "name": "Launch node.js sample", "type": "node", + "request": "launch", "program": "${workspaceRoot}/client samples/nodejs/app.js", "stopOnEntry": false, "args": [ @@ -66,6 +60,7 @@ { "name": "Launch botbuilder sample", "type": "node", + "request": "launch", "program": "${workspaceRoot}/client samples/botbuilder/index.js", "stopOnEntry": false, "args": [ @@ -78,6 +73,7 @@ { "name": "Launch ContosoFlowers sample", "type": "node", + "request": "launch", "program": "${workspaceRoot}/client samples/contosoflowers/app.js", "stopOnEntry": false, "args": [ From 2eea8f4f201d8cf80bdbaeaebfb05e82d44b29fc Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Fri, 10 Feb 2017 16:13:29 -0800 Subject: [PATCH 03/11] Reactivating correct plugins in config.json --- Server/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/config.json b/Server/config.json index ed2e465b..386f3429 100644 --- a/Server/config.json +++ b/Server/config.json @@ -143,7 +143,7 @@ "name": "Modernizr", "panel": "bottom", "foldername": "modernizrReport", - "enabled": false + "enabled": true }, { "id": "DOMTIMELINE", From 96a0f515760c4b8c39f8f4c078bbe526cf5d4b9d Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Fri, 10 Feb 2017 16:37:19 -0800 Subject: [PATCH 04/11] Fixing Socket.io when using baseUrl (should work behind proxy now!) --- Plugins/Vorlon/vorlon.clientMessenger.ts | 4 ++-- Plugins/Vorlon/vorlon.core.ts | 4 ++++ Server/Scripts/vorlon.server.ts | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Plugins/Vorlon/vorlon.clientMessenger.ts b/Plugins/Vorlon/vorlon.clientMessenger.ts index 89e469c3..14028e6c 100644 --- a/Plugins/Vorlon/vorlon.clientMessenger.ts +++ b/Plugins/Vorlon/vorlon.clientMessenger.ts @@ -54,12 +54,12 @@ this._serverUrl = serverUrl; var options = { - "path": serverUrl.split(window.location.protocol + "/")[0] + "/socket.io" + "path": serverUrl.replace(/h.*:\/\/[^\/]*/, "") + "/socket.io" } switch (side) { case RuntimeSide.Client: - this._socket = io.connect(serverUrl, options); + this._socket = io.connect(serverUrl + "/client", options); this._isConnected = true; break; case RuntimeSide.Dashboard: diff --git a/Plugins/Vorlon/vorlon.core.ts b/Plugins/Vorlon/vorlon.core.ts index fb2a17f9..99370489 100644 --- a/Plugins/Vorlon/vorlon.core.ts +++ b/Plugins/Vorlon/vorlon.core.ts @@ -48,6 +48,10 @@ Core._side = RuntimeSide.Client; Core._sessionID = sessionId; Core._listenClientId = listenClientId; + + if(serverUrl[serverUrl.length-1] === '/'){ + serverUrl = serverUrl.slice(0, -1); + } if(serverUrl.match("$https://")){ Core._isHttpsEnabled = true; diff --git a/Server/Scripts/vorlon.server.ts b/Server/Scripts/vorlon.server.ts index 38a262f0..0164b515 100644 --- a/Server/Scripts/vorlon.server.ts +++ b/Server/Scripts/vorlon.server.ts @@ -284,8 +284,14 @@ export module VORLON { javascriptFile += "if (((typeof window != 'undefined' && window.module) || (typeof module != 'undefined')) && typeof module.exports != 'undefined') {\r\n"; javascriptFile += "module.exports = VORLON;};\r\n"; + var startUrl = this.httpConfig.protocol + "://" + req.headers.host; + if(baseUrl) { + var splittedBaseUrl = baseUrl.split('//'); + startUrl = splittedBaseUrl[splittedBaseUrl.length - 1] === this.httpConfig.protocol ? baseUrl : startUrl + baseUrl; + } + if (autostart) { - javascriptFile += "\r (function() { VORLON.Core.StartClientSide('" + this.httpConfig.protocol + "://" + req.headers.host + "/', '" + req.params.idsession + "'); }());"; + javascriptFile += "\r (function() { VORLON.Core.StartClientSide('" + startUrl + "/', '" + req.params.idsession + "'); }());"; } res.header('Content-Type', 'application/javascript'); @@ -295,17 +301,20 @@ export module VORLON { } public start(httpServer: http.Server): void { + //SOCKET.IO var io = socketio(httpServer, { path: this.baseURLConfig.baseURL + "/socket.io" }); this._io = io; //Listen on / - io.on("connection", socket => { + this._io + .of(this.baseURLConfig.baseURL + "/client") + .on("connection", socket => { this.addClient(socket); }); //Listen on /dashboard - var dashboardio = io + this._io .of(this.baseURLConfig.baseURL + "/dashboard") .on("connection", socket => { this.addDashboard(socket); @@ -420,7 +429,7 @@ export module VORLON { this._sessions.all().forEach((session) => { for (var clientid in session.connectedClients) { var client = session.connectedClients[clientid]; - if ("/#" + receiveMessage.data.socketid === client.socket.id) { + if ("/client#" + receiveMessage.data.socketid === client.socket.id) { client.opened = false; if (this.dashboards[session.sessionId]) { this._log.debug(formatLog("PLUGIN", "Send RemoveClient to Dashboard " + socket.id, receiveMessage)); From c7836d51809402718826a3f6476195c09772b199 Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Sat, 11 Feb 2017 00:11:17 -0800 Subject: [PATCH 05/11] fix DashboardManager.baseUrl in dashboard --- Server/public/vorlon.dashboardManager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server/public/vorlon.dashboardManager.ts b/Server/public/vorlon.dashboardManager.ts index 7bf343bf..706204b8 100644 --- a/Server/public/vorlon.dashboardManager.ts +++ b/Server/public/vorlon.dashboardManager.ts @@ -31,8 +31,8 @@ module VORLON { var getUrl = window.location; var baseUrl = getUrl.protocol + "//" + getUrl.host; - if(this.vorlonBaseURL) { - baseUrl = this.vorlonBaseURL.split('//')[0] === getUrl.protocol ? this.vorlonBaseURL : baseUrl + this.vorlonBaseURL; + if(DashboardManager.vorlonBaseURL) { + baseUrl = DashboardManager.vorlonBaseURL.split('//')[0] === getUrl.protocol ? DashboardManager.vorlonBaseURL : baseUrl + DashboardManager.vorlonBaseURL; } VORLON.Core.StopListening(); From 86a86346c765b2b498fe8cef96c3a1f3e2ea81dc Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Sat, 11 Feb 2017 00:20:17 -0800 Subject: [PATCH 06/11] final fix for baseUrl - hopefully --- Server/public/vorlon.dashboardManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/public/vorlon.dashboardManager.ts b/Server/public/vorlon.dashboardManager.ts index 706204b8..35db9dc9 100644 --- a/Server/public/vorlon.dashboardManager.ts +++ b/Server/public/vorlon.dashboardManager.ts @@ -18,13 +18,13 @@ module VORLON { DashboardManager.SessionId = sessionid; DashboardManager.PluginsLoaded = false; DashboardManager.DisplayingClient = false; + DashboardManager.vorlonBaseURL = vorlonBaseURL; //Client ID DashboardManager.ListenClientid = listenClientid; DashboardManager.ClientList = {}; DashboardManager.StartListeningServer() DashboardManager.GetClients(); DashboardManager.CatalogUrl = vorlonBaseURL + "/getplugins/" + sessionid; - DashboardManager.vorlonBaseURL = vorlonBaseURL; } public static StartListeningServer(clientid: string = ""): void{ From a71715dc62ec91a1090001986023de79a056169f Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Sat, 11 Feb 2017 00:32:45 -0800 Subject: [PATCH 07/11] Fix vorlon.max.js route --- Server/Scripts/vorlon.server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Scripts/vorlon.server.ts b/Server/Scripts/vorlon.server.ts index 0164b515..b2eb4352 100644 --- a/Server/Scripts/vorlon.server.ts +++ b/Server/Scripts/vorlon.server.ts @@ -79,7 +79,7 @@ export module VORLON { }); app.get(this.baseURLConfig.baseURL + "/vorlon.max.js/", (req: any, res: any) => { - res.redirect("/vorlon.max.js/default"); + res.redirect(this.baseURLConfig.baseURL + "/vorlon.max.js/default"); }); app.get(this.baseURLConfig.baseURL + "/vorlon.max.js/:idsession", (req: any, res: any) => { From 65fb45cd8c0111d12c0b922b52419e06fe9a7e05 Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Sat, 11 Feb 2017 11:26:04 -0800 Subject: [PATCH 08/11] Fixing client closed with new socket management --- Server/Scripts/vorlon.server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Scripts/vorlon.server.ts b/Server/Scripts/vorlon.server.ts index b2eb4352..6c704c76 100644 --- a/Server/Scripts/vorlon.server.ts +++ b/Server/Scripts/vorlon.server.ts @@ -429,7 +429,7 @@ export module VORLON { this._sessions.all().forEach((session) => { for (var clientid in session.connectedClients) { var client = session.connectedClients[clientid]; - if ("/client#" + receiveMessage.data.socketid === client.socket.id) { + if (this.baseURLConfig.baseURL + "/client#" + receiveMessage.data.socketid === client.socket.id) { client.opened = false; if (this.dashboards[session.sessionId]) { this._log.debug(formatLog("PLUGIN", "Send RemoveClient to Dashboard " + socket.id, receiveMessage)); From 8529b10724a1a9dcd47ced1bcde1ef0e33eab6f6 Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Wed, 15 Feb 2017 09:08:38 -0800 Subject: [PATCH 09/11] Fixing baseurl for Bot Fwk inspector --- .../vorlon.botFrameworkInspector.dashboard.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Vorlon/plugins/botFrameworkInspector/vorlon.botFrameworkInspector.dashboard.ts b/Plugins/Vorlon/plugins/botFrameworkInspector/vorlon.botFrameworkInspector.dashboard.ts index 2332b20a..3bc2d9f6 100644 --- a/Plugins/Vorlon/plugins/botFrameworkInspector/vorlon.botFrameworkInspector.dashboard.ts +++ b/Plugins/Vorlon/plugins/botFrameworkInspector/vorlon.botFrameworkInspector.dashboard.ts @@ -3,7 +3,10 @@ declare var cytoscape: any; module VORLON { + declare var vorlonBaseURL: string; + export class BotFrameworkInspectorDashboard extends DashboardPlugin { + constructor() { super("botFrameworkInspector", "control.html", "control.css"); this._ready = false; @@ -114,7 +117,7 @@ module VORLON { callback(); }; - script.src = url; + script.src = vorlonBaseURL + url; document.getElementsByTagName("head")[0].appendChild(script); } From da352593b2307b03fe343256ea7fd47066d9bfca Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Wed, 15 Feb 2017 09:49:44 -0800 Subject: [PATCH 10/11] Fixing bot fwk inspector graph ui on first dialog --- Plugins/Vorlon/plugins/botFrameworkInspector/control.css | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Vorlon/plugins/botFrameworkInspector/control.css b/Plugins/Vorlon/plugins/botFrameworkInspector/control.css index cce198e8..c9fb0c5b 100644 --- a/Plugins/Vorlon/plugins/botFrameworkInspector/control.css +++ b/Plugins/Vorlon/plugins/botFrameworkInspector/control.css @@ -189,6 +189,7 @@ body { height: 100%; overflow: hidden; flex-grow: 5; + max-width: 50%; } .scroll { From 7be5ab5eb3852b1e54b87f63fc78fe7c908e5cfd Mon Sep 17 00:00:00 2001 From: Etienne Margraff Date: Wed, 15 Feb 2017 10:00:10 -0800 Subject: [PATCH 11/11] Prepare version 0.5.4 --- package.json | 2 +- whatsnew.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c780751b..cb24c618 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vorlon", - "version": "0.5.3", + "version": "0.5.4", "description": "vorlon", "main": "Server/server.js", "dependencies": { diff --git a/whatsnew.md b/whatsnew.md index 50d6bca6..2b58ade2 100644 --- a/whatsnew.md +++ b/whatsnew.md @@ -1,3 +1,11 @@ +## 0.5.4 +- Plugins + - Bot Framework Inspector + - Fixes on UI +- Vorlon behind proxy + - Fixing Socket.io when Vorlon.js is behind a proxy and BaseUrl is configured + + ## 0.5.0 - Plugins - Bot Framework Inspector