## How the HTTPD is designed ##

The pagekite.py HTTPD does:

1. XML-RPC for anything to do with controlling pagekite.py, so the
   interface can be shared between an AJAX Web-UI and a normal GUI,
   or even accessed remotely. Look into serving CORS headers to allow
   direct integration with pagekite.net/home/.

2. Static file server.

3. Embedded static files (for the default UI).

4. /vars.txt for monitoring.  Make optional?

5. Access controls for backends.


### Sharing files ###

Aside from the embedded static stuff, the served static content should
be dynamically created at runtime (but persisted to disk?).

Should support arbitrary http://vhost/path -> /local/fs/path mappings.


### Access controls ###

Shared files and directories *could* have access controls based on:

  * One-off passwords
  * Username/password pairs
  * OpenID, Facebook connect, Twitter
  * Autogenerated obscure URLs
  * Guest IP address
  * SSL certificates
  * Time (files could expire)
  * Access counts (files could expire)
  * Banning/allowing bot traffic


### Access controls for backends ###

We should be able to limit access to backend resources using some/all of
the above methods.  Granting access should/could become an interactive
process.


### Presenting human readable log info ###

The HTTP UI should give human readable information about visits to a site.
This means adding visual cues such as grouping, pictures and colors so it
is easy to see that the same person is browsing your site.

It should be possible to use clever mapping of IP addresses to colors, to
make networks more recognizable:

For example: a.b.c.d =>  rgb( (a+b+d)/3, (b+c+d)/3, (c+a+d)/3)

def ip2rgb(ip):
  # This basically gives each /24 it own hue, and then uses the final octet
  # to tune the brightness.  We avoid pitch-black and very bright colors.
  o = [int(p) for p in ip.split('.')]
  v = 55+( (19*o[3] + o[3]) % 180)
  return '#%2.2x%2.2x%2.2x' % ( (v*o[0])/256, (v*o[1])/256, (v*o[2])/256 )

for ip in ['10.1.2.3', '10.0.0.100', '127.0.0.1', '255.255.255.255',
           '178.79.140.143', '69.164.211.158', '173.230.155.164',
           '192.168.1.100', '192.168.1.1', '192.168.1.200', '192.168.1.56']:
  print ('<span style="background: %s; color: #fff; ">%s</span>'
         ) % (ip2rgb(ip), ip)

10.1.2.3    => #030103
192.168.1.1 => #5a2a30
127.0.0.1   => #200020



