On Sat, Apr 6, 2019 at 11:38 PM Nick Couchman <[email protected]> wrote:
> On Wed, Mar 13, 2019 at 1:18 PM Nick Couchman <[email protected]> wrote: > > > > > >> Looks reasonable. Naming convention within libguac for the various > >> instruction sending functions is guac_protocol_send_OPCODE(), though, so > >> this would need to be guac_protocol_send_required(). > >> > > > > I've updated the naming conventions on these... > > > > > >> > >> Perhaps the instruction should accept a list of parameter names rather > >> than > >> just a single name? This is what is done for the related "args" > >> instruction: > >> > >> > https://guacamole.apache.org/doc/1.0.0/libguac/protocol_8h.html#a6047d380b097ebc7d5f35b167e3419e6 > >> > >> > > Yeah, this was my next step, but just thought I should start with getting > > it working, then move on to making the code more efficient. > > > > > >> Client: > >> > > >> > > >> > https://github.com/necouchman/guacamole-client/commit/72de5595880baea46505cf4f9ad49640f16519e7 > >> > >> > >> Same here - convention is "onOPCODE", so this would need to be > >> "onrequired". > >> > > > > Fixed. > > > > > >> > > >> I think you will run into trouble manually parsing the Guacamole > protocol > >> with a guac_parser in a context where inbound instructions are already > >> being parsed received. Is this because the FreeRDP authentication > callback > >> must be synchronous? > >> > >> > > I'm not sure. On the xfreerdp side of things, this code results in a > > Password: prompt on the command line, and the xfreerdp app waits until > you > > enter something before proceeding. > > > > Yeah, looks like this is going to be problematic. Parsing the Guacamole > protocol while it is already running doesn't seem to work - if I use > guac_parser_expect(), it fails because there are other things going on in > the background for the connection and the argv opcode isn't the first thing > through, so it doesn't get what it's expecting. I also tried just looping > on guac_parser_read() and looking at the opcodes as they come across, > ignoring anything but argv, but it still fails. Right. You cannot have two parsers reading from the same socket, nor should protocol support be attempting to parse the Guacamole protocol manually. To handle argv, you need to provide an argv_handler to the guac_user struct. That handler will be called when argv is received. This probably means that the use of the FreeRDP authentication callback > will not work, unless > there's some other way to accomplish this. I could still try to block the > pthread until the input is received, but this might cause other problems on > the client side with an unresponsive connection? > If FreeRDP depends on this being synchronous, yes, the handler will need to block on some sort of pthread condition which is signalled when the credentials are set. Reading of the argv instruction should happen magically as long as argv_handler is properly set, as Guacamole protocol parsing is handled for you by guacd and libguac in a separate thread. If blocking will potentially result in the connection going silent, there's a function for that - guac_socket_require_keep_alive(): http://guacamole.apache.org/doc/libguac/socket_8h.html#a1d8c5111a8234c7785ae23f379f7db03 That will force the guac_socket to send a "nop" instruction roughly every 5 seconds if nothing else is sent during that period. - Mike
