A Python-backed Looking Glass in the spirit of https://github.com/telephone/LookingGlass
Branch: master
Clone or download
Latest commit eaf2ffb Sep 2, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example_configs Add die-on-term for older uwsgi to prevent lost children Jun 23, 2015
instance
static commit assets and templates Jan 20, 2015
templates Fix HTML Tag syntax Sep 2, 2015
LICENSE.txt
README.md Update README.md Jan 21, 2015
lookingglass.py
requirements.txt
ubuntu-deploy.sh enable ipv6 nginx config May 26, 2015

README.md

LookingGlass

Overview

A (simple) Python port of the LookingGlass software by telephone. HTML, CSS, and JS resources were copied and (slightly) modified, only the backend was rewritten to simplify adding new features and for XSS protection. This project uses the Flask and sh libraries and is MIT licensed.

Design Decisions

The design is much simpler than the PHP original, leaving rate limiting up to the web server (the example configs only allow 16 simultaneous connections) and configuration does involve some manual setup right now (more on this later). The original had the option of not presenting the IPv6 options, but this does not. IPv6 adoption is critical and if you are rolling out a new looking glass without IPv6 connectivity you are doing the internet a disservice.

Requirements

  • Python 2.7 (may work on earlier/later versions, not currently tested)
  • Virtualenv with all modules from requirements.txt installed (pip install -r requirements.txt)
  • The ping, mtr, traceroute, and host utilities. Other utilities may be added later.
  • A method of serving a python WSGI application. Example configs for nginx/uwsgi are included.

Setup Instructions

Example configuration files have been included for nginx and uwsgi in the example_configs folder.

nginx

The nginx config will need to be modified to change the server_name directive and any paths that differ from your installation. Copy or link it to your sites-enabled folder.

uwsgi

The uwsgi config's ini file will need to have paths modified. Pay special attention to the CONFIG_FILE env directive as this is the file you must edit to change theme, set test IPs, and change the title/location/test files. More on this in the next section. The last file you'll need for uwsgi is the wsgi.py file in example_configs/uwsgi. Copy this to the same location as lookingglass.py and edit the shebang line to reflect your virtualenv.

lookingglass

The default configuration file is in instance/default.cfg. Copy this to another cfg file (instance/lg.cfg for example) and ensure this path is specified in your lg.ini uwsgi config. Edit this file to customize your installation. You will need to create test files that you reference. For example, if you have a 100MB and 1000MB test file specified in your config, you would use the following commands to create them:

dd if=/dev/zero of=static/100MB.test bs=1 count=0 seek=100MB
dd if=/dev/zero of=static/1000MB.test bs=1 count=0 seek=1000MB

Keep in mind that the above files count in SI units, not IEC. The result is that 1Kilobyte==1000Bytes instead of 1024, as you may expect. To get that behavior, use MiB instead of MB.

API

The API is extremely simple. There are two encoding methods, raw and json. Raw output is still escaped (flask.escape) for safety. JSON output uses JSON escapes. All endpoints take only variable, host, in the query string. The value is validated and passed to the underlying function. Example endpoints:

/raw/ping4
/json/mtr6
/json/host
/raw/host

License

Code is licensed under MIT Public License.