On Tue, Nov 1, 2016 at 2:25 AM, Nikola Malešević <[email protected] > wrote:
> Hello, > > I would like to time-limit each connection by a set of rules that are > contained in my local database. For instance, some sessions would be > limited to 30 minutes, some to 14, it depends from connection to connection. > > I am not sure how I can kill the connection from server-side. I have > already developed an extension for authentication using Moodle log-in and > remote end-point connection data, but now I need to also close that same > connection after some period of time. > > The best would be if there was something like > SimpleAuthenticationProvider (but for connection handling) that I could > extend to suit my needs. > > If you wish for your extension to close a connection, all it needs to do is invoke the close() function on the associated GuacamoleTunnel. Each Connection implementation is required to provide a connect() function which returns a GuacamoleTunnel, so you can use that as a means of extending/overriding the tunnel, automatically closing after some amount of time has elapsed. The DelegatingGuacamoleTunnel class may be an easy way of doing that, if you're already using the Simple* implementations. I'd suggest having a single extension-wide structure containing all currently-active connections, along with a monitoring thread which kicks in every minute or so to close() connections which are too old, rather than having a ton of per-connection threads, especially if you're OK with limiting granularity to +/- 1 minute. We use a similar algorithm for tracking and expiring the authentication tokens associated with user sessions within the Guacamole webapp. Thanks, - Mike
