From dc882b08efa656eb881ffcd266846fd6dcef131d Mon Sep 17 00:00:00 2001 From: myers_carpenter Date: Sun, 9 Mar 2003 16:33:02 +0000 Subject: [PATCH] * adding setup.py, and __init__.py to make this installable package. * Adding some links to README.txt, updating about depenancies, and formating fixes * Removing out of date script for debian --- DEBIAN.sh | 15 ------------ README.txt | 66 +++++++++++++++++++++++++++++++++++++++-------------- __init__.py | 0 setup.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 32 deletions(-) delete mode 100644 DEBIAN.sh create mode 100644 __init__.py create mode 100755 setup.py diff --git a/DEBIAN.sh b/DEBIAN.sh deleted file mode 100644 index c1529c3..0000000 --- a/DEBIAN.sh +++ /dev/null @@ -1,15 +0,0 @@ -# How To Install Khashmir on Debian - -cd .. -sudo apt-get install python2.2 -wget http://us.dl.sourceforge.net/twisted/Twisted-0.99.1rc4.tar.gz -wget http://us.dl.sf.net/pybsddb/bsddb3-3.4.0.tar.gz -tar xzf Twisted-0.99.1rc4.tar.gz -cd Twisted-0.99.1rc4 -sudo python2.2 setup.py install -cd .. -tar xzf bsddb3-3.4.0.tar.gz -cd bsddb3-3.4.0 -sudo python2.2 setup.py install --berkeley-db=/usr -cd ../khashmir -python2.2 test.py \ No newline at end of file diff --git a/README.txt b/README.txt index 1ced5c9..093cc96 100644 --- a/README.txt +++ b/README.txt @@ -1,14 +1,31 @@ -Khashmir is a distributed hash table that uses an XOR distance metric and a routing table similar to Kademlia. Use Khashmir to build distributed applications. Note that Khashmir currently isn't very attack resistant. - -Khashmir is implemented in Python using the Twisted asynchronous networking framework. IPC is done via HTTP/XML-RPC. BerkeleyDB is used for each peer's backing store of keys and values. The backing store is currently held in memory but it could easily be placed on disk. Values expire after 24 hours, by default. Each peer stores multiple values for a key and currently returns all available values when requested. - -If you just want to watch it build a test network of peers, run "python khashmir.py " -This script will create the specified number of peers, give each one three random contacts, tell each one to find the closest nodes, then pick a random peer and have it find another random peer (ten times), then pick a random peer to insert a key/value and have three random peers try to find it (ten times.) - +[Note: I have no idea how up to date the code examples are -- icepick ] + +Khashmir is a distributed hash table that uses an XOR distance metric and a +routing table similar to Kademlia [1]. Use Khashmir to build distributed +applications. Note that Khashmir currently isn't very attack resistant. + + 1 - http://kademlia.scs.cs.nyu.edu/ + +Khashmir is implemented in Python using the Twisted [2] asynchronous networking +framework. Network deliver is done using Airhook [3]. PySQLite is used for each +peer's backing store of keys and values. The backing store is currently +held in memory but it could easily be placed on disk. Values expire after +24 hours, by default. Each peer stores multiple values for a key and +currently returns all available values when requested. + + 2 - http://twistedmatrix.com + 3 - http://airhook.org/ + +If you just want to watch it build a test network of peers, run "python +khashmir.py " This script will create the specified number of +peers, give each one three random contacts, tell each one to find the +closest nodes, then pick a random peer and have it find another random peer +(ten times), then pick a random peer to insert a key/value and have three +random peers try to find it (ten times.) quick example: ->>> k = khashmir.test_one('', 4444) # chosose any port +>>> k = khashmir.test_one('', 4444) # choose any port - which is the same thing as - @@ -17,32 +34,47 @@ quick example: >>> thread.start_new_thread(k.app.run, ()) -If you want to make another peer in the same session, use peer = khashmir.Khashmir(host, port) then do peer.app.run() to register with the already running thread. +If you want to make another peer in the same session, use + +>>> peer = khashmir.Khashmir(host, port) +then do -Now you need some contacts. Add as some contacts and try to find close nodes in the network. +>>> peer.app.run() + +to register with the already running thread. + + +Now you need some contacts. Add as some contacts and try to find close +nodes in the network. >>> k.addContact('127.0.0.1', 8080) # locate another peer >>> k.findCloseNodes() # query the network to bootstrap our table -Keys are always 20-character strings (sha1 hashes) -currently there is no limit to value sizes, something will go in ASAP - +Keys are always 20-character strings (sha1 hashes) currently there is no +limit to value sizes, something will go in ASAP Now try storing and retrieving values. -# callback returns node info dictionaries and actual connection information for peers that accepted the value -# currently finds the K closest nodes and makes one attempt to store them +# callback returns node info dictionaries and actual connection information +# for peers that accepted the value. Currently finds the K closest nodes and +# makes one attempt to store them >>> k.storeValueForKey(key, value, callback=None) -# callback returns lists of values, will fire multiple times, last time will be an empty list +# callback returns lists of values, will fire multiple times, last time will +# be an empty list >>> k.valueForKey(key, callback) TWEAKABLE SETTINGS: -ktable.py: K - the size of routing table buckets, how many nodes to return in response to find-node/value request, and how many nodes to issue storeValue to; default is 8, which should work for hundreds of nodes, you might want to bump it if you think your network is going to be large +ktable.py: + K - the size of routing table buckets, how many nodes to return + in response to find-node/value request, and how many nodes to issue + storeValue to; default is 8, which should work for hundreds of + nodes, you might want to bump it if you think your network is going + to be large A bunch of other tweakables are in const.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..52d6c52 --- /dev/null +++ b/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +import os +import sys + +try: + import distutils.core + import distutils.command.build_ext +except ImportError: + raise SystemExit, """\ +You don't have the python development modules installed. + +If you have Debian you can install it by running + apt-get install python-dev + +If you have RedHat and know how to install this from an RPM please +email us so we can put instructions here. +""" + +try: + import twisted +except ImportError: + raise SystemExit, """\ +You don't have Twisted installed. + +Twisted can be downloaded from + http://twistedmatrix.com/products/download + +Anything later that version 1.0.3 should work +""" + +try: + import sqlite +except ImportError: + raise SystemExit, """\ +You don't have PySQLite installed. + +PySQLite can be downloaded from + http://sourceforge.net/project/showfiles.php?group_id=54058&release_id=139482 +""" + +setup_args = { + 'name': 'khashmir', + 'author': 'Andrew Loewenstern', + 'author_email': 'burris@users.sourceforge.net', + 'licence': 'MIT', + 'package_dir': {'khashmir': '.'}, + 'packages': [ + 'khashmir', + ], +} + +if hasattr(distutils.dist.DistributionMetadata, 'get_keywords'): + setup_args['keywords'] = "internet tcp p2p" + +if hasattr(distutils.dist.DistributionMetadata, 'get_platforms'): + setup_args['platforms'] = "win32 posix" + +if __name__ == '__main__': + apply(distutils.core.setup, (), setup_args) -- 2.39.5