mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Require "enable-websocket" property to be set to "true" before enabling WebSocket support.
This commit is contained in:
		| @@ -25,6 +25,8 @@ import javax.servlet.ServletContext; | |||||||
| import javax.servlet.ServletContextEvent; | import javax.servlet.ServletContextEvent; | ||||||
| import javax.servlet.ServletContextListener; | import javax.servlet.ServletContextListener; | ||||||
| import org.glyptodon.guacamole.GuacamoleException; | import org.glyptodon.guacamole.GuacamoleException; | ||||||
|  | import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty; | ||||||
|  | import org.glyptodon.guacamole.properties.GuacamoleProperties; | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
| @@ -37,6 +39,17 @@ import org.slf4j.LoggerFactory; | |||||||
|  * not be available or needed if WebSocket is not desired, the 3.0 API is |  * not be available or needed if WebSocket is not desired, the 3.0 API is | ||||||
|  * detected and invoked dynamically via reflection. |  * detected and invoked dynamically via reflection. | ||||||
|  *  |  *  | ||||||
|  |  * Tests have shown that while WebSocket is negligibly more responsive than | ||||||
|  |  * Guacamole's native HTTP tunnel, downstream performance is not yet a match. | ||||||
|  |  * This may be because browser WebSocket implementations are not optimized for | ||||||
|  |  * throughput, or it may be because servlet container WebSocket implementations | ||||||
|  |  * are in their infancy, or it may be that OUR WebSocket-backed tunnel | ||||||
|  |  * implementations are not efficient. Because of this, WebSocket support is | ||||||
|  |  * disabled by default. To enable it, add the following property to | ||||||
|  |  * your guacamole.properties: | ||||||
|  |  *  | ||||||
|  |  *     enable-websocket: true | ||||||
|  |  * | ||||||
|  * @author Michael Jumper |  * @author Michael Jumper | ||||||
|  */ |  */ | ||||||
| public class WebSocketSupportLoader implements ServletContextListener { | public class WebSocketSupportLoader implements ServletContextListener { | ||||||
| @@ -46,6 +59,16 @@ public class WebSocketSupportLoader implements ServletContextListener { | |||||||
|      */ |      */ | ||||||
|     private Logger logger = LoggerFactory.getLogger(WebSocketSupportLoader.class); |     private Logger logger = LoggerFactory.getLogger(WebSocketSupportLoader.class); | ||||||
|  |  | ||||||
|  |     private static final BooleanGuacamoleProperty ENABLE_WEBSOCKET = | ||||||
|  |             new BooleanGuacamoleProperty() { | ||||||
|  |  | ||||||
|  |         @Override | ||||||
|  |         public String getName() { | ||||||
|  |             return "enable-websocket"; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     }; | ||||||
|  |      | ||||||
|     /** |     /** | ||||||
|      * Classname of the Jetty-specific WebSocket tunnel implementation. |      * Classname of the Jetty-specific WebSocket tunnel implementation. | ||||||
|      */ |      */ | ||||||
| @@ -108,10 +131,10 @@ public class WebSocketSupportLoader implements ServletContextListener { | |||||||
|  |  | ||||||
|         // If no such servlet class, WebSocket support not present |         // If no such servlet class, WebSocket support not present | ||||||
|         catch (ClassNotFoundException e) { |         catch (ClassNotFoundException e) { | ||||||
|             logger.info("WebSocket support not found.", e); |             logger.info("WebSocket support not found."); | ||||||
|         } |         } | ||||||
|         catch (NoClassDefFoundError e) { |         catch (NoClassDefFoundError e) { | ||||||
|             logger.info("WebSocket support not found.", e); |             logger.info("WebSocket support not found."); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Log all GuacamoleExceptions |         // Log all GuacamoleExceptions | ||||||
| @@ -131,6 +154,19 @@ public class WebSocketSupportLoader implements ServletContextListener { | |||||||
|     @Override |     @Override | ||||||
|     public void contextInitialized(ServletContextEvent sce) { |     public void contextInitialized(ServletContextEvent sce) { | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |  | ||||||
|  |             // Stop if WebSocket not explicitly enabled. | ||||||
|  |             if (!GuacamoleProperties.getProperty(ENABLE_WEBSOCKET, false)) { | ||||||
|  |                 logger.info("WebSocket support not enabled."); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |         catch (GuacamoleException e) { | ||||||
|  |             logger.error("Error parsing enable-websocket property.", e); | ||||||
|  |         } | ||||||
|  |          | ||||||
|         // Try to load websocket support for Jetty |         // Try to load websocket support for Jetty | ||||||
|         logger.info("Attempting to load Jetty-specific WebSocket support..."); |         logger.info("Attempting to load Jetty-specific WebSocket support..."); | ||||||
|         if (loadWebSocketTunnel(sce.getServletContext(), JETTY_WEBSOCKET)) |         if (loadWebSocketTunnel(sce.getServletContext(), JETTY_WEBSOCKET)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user