From 1b4181a200024014bc8e6e0fc965f23f0d5c6baf Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 9 Dec 2015 21:15:15 -0800 Subject: [PATCH 1/3] GUAC-1430: Do not move on to the next chained tunnel on upstream timeout. --- .../src/main/webapp/modules/Tunnel.js | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Tunnel.js b/guacamole-common-js/src/main/webapp/modules/Tunnel.js index e4db1d7d9..fcd9fe988 100644 --- a/guacamole-common-js/src/main/webapp/modules/Tunnel.js +++ b/guacamole-common-js/src/main/webapp/modules/Tunnel.js @@ -884,12 +884,23 @@ Guacamole.ChainedTunnel = function(tunnel_chain) { /** * Fails the currently-attached tunnel, attaching a new tunnel if * possible. - * + * * @private - * @return {Guacamole.Tunnel} The next tunnel, or null if there are no - * more tunnels to try. + * @param {Guacamole.Status} [status] + * An object representing the failure that occured in the + * currently-attached tunnel, if known. + * + * @return {Guacamole.Tunnel} + * The next tunnel, or null if there are no more tunnels to try or + * if no more tunnels should be tried. */ - function fail_tunnel() { + var failTunnel = function failTunnel(status) { + + // Do not attempt to continue using next tunnel on server timeout + if (status && status.code === Guacamole.Status.Code.UPSTREAM_TIMEOUT) { + tunnels = []; + return null; + } // Get next tunnel var next_tunnel = tunnels.shift(); @@ -904,7 +915,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) { return next_tunnel; - } + }; /** * Use the current tunnel from this point forward. Do not try any more @@ -933,7 +944,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) { // If closed, mark failure, attempt next tunnel case Guacamole.Tunnel.State.CLOSED: - if (!fail_tunnel() && chained_tunnel.onstatechange) + if (!failTunnel() && chained_tunnel.onstatechange) chained_tunnel.onstatechange(state); break; @@ -957,7 +968,7 @@ Guacamole.ChainedTunnel = function(tunnel_chain) { tunnel.onerror = function(status) { // Mark failure, attempt next tunnel - if (!fail_tunnel() && chained_tunnel.onerror) + if (!failTunnel(status) && chained_tunnel.onerror) chained_tunnel.onerror(status); }; From f3ff3f62c7eedc51c252cf96e872d108463cc175 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 9 Dec 2015 21:39:07 -0800 Subject: [PATCH 2/3] GUAC-1430: Wrap error to ensure that required fields are always present. --- .../src/main/webapp/app/auth/service/authenticationService.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guacamole/src/main/webapp/app/auth/service/authenticationService.js b/guacamole/src/main/webapp/app/auth/service/authenticationService.js index 5dd549a34..51042a1e5 100644 --- a/guacamole/src/main/webapp/app/auth/service/authenticationService.js +++ b/guacamole/src/main/webapp/app/auth/service/authenticationService.js @@ -155,6 +155,10 @@ angular.module('auth').factory('authenticationService', ['$injector', // If authentication fails, propogate failure to returned promise .error(function authenticationFailed(error) { + // Ensure error object exists, even if the error response is not + // coming from the authentication REST endpoint + error = new Error(error); + // Request credentials if provided credentials were invalid if (error.type === Error.Type.INVALID_CREDENTIALS) $rootScope.$broadcast('guacInvalidCredentials', parameters, error); From 28ff969d32f0bce0a09b3b045ebb7381d1ef45bc Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 9 Dec 2015 21:41:47 -0800 Subject: [PATCH 3/3] GUAC-1430: Always show connection closed status after authentication update attempt. --- .../main/webapp/app/client/controllers/clientController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 572724f41..fd445d1c7 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -441,8 +441,8 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams // Re-authenticate to verify auth status at end of connection authenticationService.updateCurrentToken($location.search()) - // If authentication is OK, show the requested status - .then(function authenticationCheckSuccessful() { + // Show the requested status once the authentication check has finished + ['finally'](function authenticationCheckComplete() { guacNotification.showStatus(status); });