On Fri, Sep 27, 2024 at 5:48 PM Greg Tomsho <gtsh...@gmail.com> wrote:
> Hello: > > I'm writing a Gauacamole app using the tutorial from the Guacamole web > site: > https://guacamole.incubator.apache.org/doc/gug/writing-you-own-guacamole-app.html > > When I g to create a configuration for a new tunnel (Java code), I want to > be able to pass in the configuration information from the web client > (javascript) instead of hard-coding it. How can I get that information? See > Java code and javascript web client code below. > There is a rather broad question, but it is completely doable. How you do it is really up to you - you just need a way of collecting the data from the user (a form, prompts, etc.) and then, instead of hard-coding that information, provide the input from the user to the Java class. Rather than describe that all, here, I'd say take a look at the fully Guacamole Client code and see how it's done, there - in particular: * The REST API code ( https://github.com/apache/guacamole-client/tree/main/guacamole/src/main/java/org/apache/guacamole/rest), which generally, in Guacamole, handles the interface between the front-end (JavaScript) application and the back-end bits. * The QuickConnect extension ( https://github.com/apache/guacamole-client/tree/main/extensions/guacamole-auth-quickconnect) which has bits specifically for taking input (a URI, in that case) from a user and creating a Connection out of it. I know this is pretty general information, but there's plenty of existing code out there that shows you how to interface between JavaScript and Java, so taking a look at that would probably get you going in the right direction, and then you're welcome to come back and ask further questions, here, if you like. > Any help would be much appreciated. On a side note, can this be done in > pure client-side javascript without the server-side java? > > > Can it be done purely in client-side JavaScript? Maybe. However, it would be challenging - aside from the creation of a connection by gathering data from a user, the other part that the server-side Java code facilitates is the tunneling of the Guacamole Protocol over HTTP(S) and/or WebSockets (WS/WSS). It isn't that this has to be done over Java, just that Java makes it relatively easy and also, in the case of the full Guacamole Client, anyway, provides the mechanisms for authorizing and securing those connections. There are other systems out there that can do the TCP/WebSocket translation, and you might even be able to talk directly to guacd with JavaScript, but you need some way of preventing that from being abused by someone else who may have access to the guacd port/socket. -Nick >