iclab/centinel-iclab — pull request #49 by gsathya (2014-09-02 04:26:32+00:00)
Title: Refactor

This is a pretty insane pull request.

## Server
I completely rewrote the server to use REST instead of the custom protocol.
### Problems with custom protocol
* Using `|` as a separator caused all kinds of breakage
* Not tested
* Custom TLS and network handling code
* Very hard to extend

### REST
* Highly tested
* Super easy to extend
* TLS for free
* Super easy auth
* Easy proxy support
and more ...

Here's the new server code:
http://github.com/gsathya/centinel-server/

Here's the server API:
https://github.com/gsathya/centinel-server/blob/master/docs/api.md

## Client
I backported most of the changes done in the summer. Here's a list of changes -

* Add logging
* Add config file for centinel client
* Make centinel client talk REST to server
* Add CLI args
* Add proxy support
* Add HTTP authentication -- The client cert handshake is not necessary anymore, instead the client automagically registers on startup.
* Not adding onlineapis -- No need for centinel client to do this - User should do this with a offline geoip database
* No need for netlib -- HTTP does everything for us
* Not adding colors.py -- Platform dependent code that could break easily
* Not adding auto update -- Pip can do this easily. Here's a simple crom to do this ```0 22 * * * pip install centinel --upgrade```
* Not adding beat -- There's no need for this. We can make the client sync with the server every minute with a cron job.

### TODO
* I still need to do copy the service script and Ben's experiments

## Primitives
I've not backported the configurable tests. I think the config as an experiment is a fundamentally limiting design resulting in a ton of if-else spaghetti code in the primitives. Instead, I've designed a javascript app the generates executable python code using a templating engine. This gives a ton of control and power over designing the web interface.

The current primitives are:
* HTTP
* DNS

## Maker - Web UI
As mentioned above, the source code for the Web UI is here:
https://www.github.com/gsathya/maker

Here's a preview:
http://gsathya.in/maker/

The skeleton template for experiment is here:
https://github.com/gsathya/maker/blob/master/index.html#L135

The code for compiling the template is here:
https://github.com/gsathya/maker/blob/master/js/maker.js

## Android app
Here are the instructions to building centinel for Android:
https://github.com/projectbismark/centinel/wiki/Android

## Kobra
As far as I could understand Kobra is used to get data from server. With the current REST API, we can just `curl` all the result files.

## Notes

I would recommend not merging this to `master` because -
* It would make the git history dirty and useless
* You'd have to deal with a ton of merge conflicts

Instead, I'd recommend just using this branch as the `master` going forward.

Thoughts?