Exablaze logo

EXABLAZE

BLOG | MEDIA

KEEP UP TO DATE BY READING OUR BLOG AND NEWS FROM AROUND THE WEB

AUTHOR:

DATE:

Using ExaLINK as a kill switch

In this blog I want to go over how a web application can be written to control an ExaLINK, for example a kill switch.

The ExaLINK is touted for its low latency and ability for remote management. Rather than allow full configuration access to all users, you may want to allow different sets of functionality to different groups of people. For example, you may want an account manager to be able to activate a kill switch, but only allow system adminitrators to manage port configuration. One approach to this, is to provide web applications with suitable functionality for the particular users. In this blog we demonstrate how one could set up a web application to make use the the ExaLINK's API to perform specific tasks.

JSON API

Some features that are accessible in the ExaLINK's web interface are also accessible through POST requests. The request and response are encoded in structured JSON.

For any set of ports, one can query:

  • SFP absence or presence (and its status)
  • Port redirection
  • Port status (enabled or disabled)

For any set of ports, one can set:

  • Port redirection
  • Port status (enable or disable)

In our example, we imagine an account manager being able to control whether a client has access to a service. In other words, we want a user to be able to disable or enable a particular port pairing. Using a command line tool, such as curl, one can perform some basic configuration and maintenance on an ExaLINK.

For example, to enable ports 15, 16 and 17:

 curl -H 'Accept: application/json' \
  -X POST http://192.168.0.1/cgi-bin/api \
  -d '{ "auth":{ "username":"user", "password":"pass"},
                    "set":{ "enable":[15,16,17] } }'

WebApp

It is easier and more intuitive to present the required functionality through a web page. This is safer too, as all relevant data and options can be presented in a single place, and easily updated as required.

The example we have produced (available from GitHub ) is functional. We leave it as an exercise for the reader to improve its appearance. Similarly we do not attempt to address web security in this blog.

The first thing to note is that the ExaLINK's api makes use of POST requests. That means that we are not able to submit data directly to the ExaLINK, as browsers block POST's to different domains. For this reason, we provide the functionality in a separate web server, using node. The web server is able to post requests to a different domain.

In our example, the account manager has access to three clients, and is easily able to disable/enable any of them. The node application, control.js, provides underlying functionality for the page client.html. The page submits a get request to the node app, to get the current status. It uses a timer to periodically get updates. There are two pieces of information we are after for each port:

  • whether there is an SFP present and active
  • whether the port is redirected to the expected location.

These are represented by fields "status" and "linked" in our example, see

Diagram showing normal web app output

Depending on the status returned from the node app, we display different data in a table:

  • If there is no SFP, then no user action makes sense and no button is displayed.
  • If the port is not redirected to the expected location, we display the button to reset the port forwarding.

    As shown below:-

Diagram showing port needing to be relinked

  • If the port is disabled, we display a button to enable it
  • If the port is enabled, the button allows it to be disabled.

Diagram showing disabled port

In each case, the button results in a simple post request being made to the node app. The node app then constructs and sends the appropriate JSON structure to the ExaLINK.

Please take the code and craft your own version of a kill switch.

As usual if you have any questions or want more information about anything we've discussed in this blog, get in touch!