npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fordaudiovideo/guacamole-gateway-ts

v0.2.14

Published

NodeJs Typescript Socket.io gateway for guacamole

Downloads

87

Readme

guacamole-gateway-ts

Synopsis

Typescript guacamole-gateway-ts is a NodeJS replacement for guacamole-client (server-side Java servlet). Guacamole is a RDP/VNC client for HTML5 browsers. This is a fork of vadimpronin excellent work on guacamole-lite.

This solution allows dynamic control of encryption and decryption inside your node. This also requires an express server and socket.io.

This diagram describes the architecture of Guacamole and the role of guacamole-gateway-ts in it: Chart

Installation

npm install --save guacamole-gateway-ts

To connect to guacamole-gateway-ts as a client please see the Angular component 'guacamole-gateway-client' NPM Link

Setting up the Server

import { Server as httpsServer, createServer } from 'https';		//Secure for SSL
import express, { Request, Response, NextFunction } from "express";
import { SocketIOGatewayServer, logLevel, log_settings, preProcess } from 'guacamole-gateway-ts';

    var listen_port = 4823;
    var app = express();
    var options = {
        key: readFileSync("/{{path to key}}/key.pem", "utf8"),
        cert: readFileSync("/{{path to key}}/certbundle.pem", "utf8"),
    };
    var server: httpsServer = createServer(options, app);

    const guacdOpt: guacdOptions = {
        port: 4822 // default guacd port
    };

    //Setting up log options is optional.
    const log_options: log_settings = {
        level: logLevel.DEBUG,
        stdLog: (...args) => {
            console.log('[GATEWAY LOG]', ...args);
        },
        errorLog: (...args) => {
            console.error('[GATEWAY ERROR]', ...args);
        }
    }


    //This is a sample authentication callback that will be processed prior to any connections being made. Excluding this and left unsecured is not advised. 
    const auth: preProcess = async ( options: {auth: any, type?: 'client'|'agent'}, callback: (error: any, room: string) => void ): Promise<void> => {
        try {
            if( options.auth && options.auth.optionalExtraAuthenticaitonToken){
                switch(options.type){
                    case 'client':{
                        //browser
                        //Do your authenticaiton and identification here. Simply pass the "room" the client will connect to. The agent will need to do its own authentication and indentification and then match this room
                        return callback(null, "my_custom_roomXYZ");
                        break;
                    }
                    case 'agent':{
                        //remote agent (machine you want to RD into)
                        //Do your authenticaiton and identification here. Simply pass the "room" the agent will connect to. The client will need to do its own authentication and indentification and then match this room
                        return callback(null, String(rmmClient.bbo_contnum));
                        break;
                    }
                }
            } 
        } catch (err) {
            console.error(err);
            return callback(err, '');
        }

        console.error('Invalid Login Attempt');
        return callback(new Error('Invalid Login Attempt'), '');
    }

    const socketIOGateway: SocketIOGatewayServer = new SocketIOGatewayServer(server, log_options, auth);

    socketIOGateway.on('open', (clientConnection) => { console.log('OPEN', clientConnection) });
    socketIOGateway.on('close', (clientConnection) => { console.log('CLOSE', clientConnection) });
    socketIOGateway.on('error', (clientConnection, error) => { console.error(clientConnection, error) });

    server.listen(listen_port, () => {
        console.log('Guacamole Gateway Server - online and listening on port: ' + listen_port);
    });

Log levels

clientOptions.log.level defines verbosity of logs. Possible values are:

  • "QUIET" - no logs
  • "ERRORS" - only errors
  • "NORMAL" - errors + minimal logs (startup and shutdown messages)
  • "VERBOSE" - (default) normal + connection messages (opened, closed, guacd exchange, etc)
  • "DEBUG" - verbose + all OPCODES sent/received within guacamole sessions

Custom log functions

By default guacamole-gateway-ts uses console.log and console.error functions for logging. You can redefine these functions by setting clientOptions.log.stdLog and clientOptions.log.errorLog like in the example below. Note that clientOptions.log.level is still applied, which means that messages that don't match desired log level won't be sent to your custom functions


const clientOptions = {
    log: {
        level: 'DEBUG',
        stdLog: (...args) => {
            console.log('[MyLog]', ...args)
        },
        errorLog: (...args) => {
            console.error('[MyLog]', ...args)
        }
    }
};

Associated Components

guacamole-gateway-client

Apache Guacamole