Code Monkey home page Code Monkey logo

lookingglass's Introduction

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.

lookingglass's People

Contributors

gusnaughton avatar redkrieg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.