Skip to content

andrewcooke/GhettoNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to GhettoNet!
======================


Introduction
------------

GhettoNet helps you see censored websites by adding their names to the "hosts"
file on your computer.  It can pull updates from the web, or read them from a
file (perhaps a saved email).  It can also print out the addresses you have so
that you can send them to a friend.  And you can add or delete particular
entries yourself.

This initial version of GhettoNet is a "command line app".  That means that
it must be run from a prompt, as a privileged user.  If you don't know what
that means then you need more help - I can't explain everything here, but I
hope that other people will, so please search on the Internet for advice.

To see all the options available, run ghettonet.py with the "-h" argument
or checked the "Help Output" section below.

Requires Python 2.4 or later.


File Format
-----------

GhettoNet data can be embedded in files a variety of formats.  A valid data
block is detected by:
o  splitting into lines based on (optional) carriage return and newline.
o  looking for the begin line
o  reading all data lines until the (optional) end line or bad data

More than one data block may be present in a file.

A valid data line is one of:
o  a comment, prefixed by #
o  a blank line
o  a date (simplified ISO 8601: yyyy-mm-dd hh:mm:ss) prefixed by ## DATE
o  a valid IPv4 line (only, currently) for a hosts file 
Any other data are taken to indicate the end of the block (if these don't
match the end line then a warning is given; if we are parsing hosts then
we refuse to continue).

The aim above is to define something that is easy for people to generate and
send, and which can be stored directly in the hosts file, but which has a 
low probability of causing errors.

The date indicates when the information was known and is used to prioritise
conflicting entries, if present (most recent date wins).

Indentation and blank lines are optional, as are the comment and date.

The most important part of this program is the file format.  Please write new
clients or design new ways of spreading this data - this is very much a proof
of concept (and, I hope, a library others can build on).


Help Output
-----------

Usage: 

  ghettonet.py [options]

GhettoNet manages IPv4/DNS data in a format compatible with hosts files.

The format can be easily embedded in files, emails and web pages:

  ### BEGIN GHETTONET
  213.251.145.96    www.wikileaks.org wikileaks.org
  ### END GHETTONET

By default, all inputs are combined and written to stdout.  Inputs are
taken from the local hosts file, any files specified with '-i', and any
URLs specified with '-u'.

If the -w option is given then hosts is written to instead.


Examples:

  To update your hosts file from the file 'new-addresses.txt'
    ghettonet.py -w -i new-addresses.txt

  To update hosts from a URL
    ghettonet.py -w -u https://github.com/ghettonet/GhettoNet
  Since updating a hosts file requires system privileges, a typical use on
  Linux might look like:
    sudo ./ghettonet.py -w -u https://github.com/ghettonet/GhettoNet

  To display ghettonet entries in your hosts file
    ghettonet.py

  To remove all ghettonet entries from your hosts file
    ghettonet.py -w -x

  To add an address:
    ghettonet.py -w -4 1.2.3.4 -n example.com

  To remove an address:
    ghettonet.py -w -r 1.2.3.4


Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -q, --quiet           suppress messages
  -t, --test            run doctests

  Sources:
    -i FILE, --input=FILE
                        read input from FILE (repeatable)
    -s, --stdin         read input from a pipe
    -u URL, --url=URL   read input from URL (repeatable)

  Hosts file:
    -p PATH, --path=PATH
                        path to hosts file
    -w, --write         write to the hosts file
    -x, --exclude       exclude the hosts file from input

  Add an entry:
    -4 IPV4, --ipv4=IPV4
                        IPv4 address to add
    -n NAME, --name=NAME
                        name to add (repeatable)
    -c COMMENT, --comment=COMMENT
                        comment to add (repeatable)
    -d DATE, --date=DATE
                        date to add

  Remove entries:
    -r IPV4, --remove=IPV4
                        IPv4 address to remove (repeatable)


Licence
-------

This code is placed into the public domain.  You can do whatever you want with
it, but it comes with no warranty or guarantee.


Example
-------

To load the example data below on Linux use
  sudo ghettonet.py -w -u https://github.com/ghettonet/GhettoNet


### BEGIN GHETTONET

## DATE 2010-12-05
# see http://www.guardian.co.uk/media/2010/dec/05/wikileaks-internet-backlash-us-pressure
# 213.251.145.96 also working
88.80.13.160 www.wikileaks.org wikileaks.org

## DATE 2010-12-05
# from torrent-finder.info
# see http://thegoodnetguide.com/tag/torrent-finder/
208.101.51.56 www.torrent-finder.com torrent-finder.com

## DATE 2010-12-05
# from rapgodfathers.info
# see http://thegoodnetguide.com/tag/torrent-finder/
199.27.134.101 www.rapgodfathers.com rapgodfathers.com

### END GHETTONET

About

Avoid DNS censorship; use GhettoNet to pull, manage and share name/IP entries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published