# Configuration file for git-buildpackage and friends
[DEFAULT]
-debian-branch = apt-dht
+debian-branch = apt-p2p
debian-tag = %(version)s
[git-buildpackage]
Unless otherwise noted, all files are released under the GNU General
Public License, exceptions are noted below.
-Apt-dht is Copyright (C) 2008 Cameron Dale <camrdale@gmail.com>
+Apt-p2p is Copyright (C) 2008 Cameron Dale <camrdale@gmail.com>
-Apt-dht is licensed under the terms of the GNU General Public License (GPL),
+Apt-p2p is licensed under the terms of the GNU General Public License (GPL),
version 2 or later, as published by the Free Software Foundation. See
/usr/share/common-licenses/GPL, or <http://www.gnu.org/copyleft/gpl.txt>
for the terms of the latest version of the GNU General Public License.
-The module apt_dht_Khashmir is a modified version of the original khashmir,
+The module apt_p2p_Khashmir is a modified version of the original khashmir,
the source of which can be found at http://sourceforge.net/projects/khashmir.
It is covered by the following copyright and permission notice:
-Apt-DHT: a peer-to-peer proxy for apt downloads
+Apt-P2P: a peer-to-peer proxy for apt downloads
### Goal
-Similar to DebTorrent[1], Apt-DHT will act as a proxy between apt
+Similar to DebTorrent[1], Apt-P2P will act as a proxy between apt
requests and a debian repository server, downloading any requested
files from peers (if possible), but falling back to a direct HTTP
-download. Unlike DebTorrent, Apt-DHT will be simple, efficient, and
+download. Unlike DebTorrent, Apt-P2P will be simple, efficient, and
fast.
[1]: http://debtorrent.alioth.debian.org/
### Installing
There are detailed instructions on the web site[6] showing how to
-install the Apt-DHT program. If you have any trouble using the
+install the Apt-P2P program. If you have any trouble using the
program, you can email me[7], or come and find me in the
DebTorrent IRC channel (#debtorrent on OFTC[8]). If you think
you've found a bug in the program, please let me know.
-[6]: http://www.camrdale.org/apt-dht.html
+[6]: http://www.camrdale.org/apt-p2p.html
[7]: mailto:camrdale@gmail.com
[8]: http://irc.oftc.net
python-apt, the code for which is based on that of the
apt-proxy[12] program.
-[9]: http://git.camrdale.org/?p=apt-dht.git;a=summary
+[9]: http://git.camrdale.org/?p=apt-p2p.git;a=summary
[10]: http://khashmir.sourceforge.net/
[11]: http://en.wikipedia.org/wiki/Kademlia
[12]: http://apt-proxy.sourceforge.net/
-# The apt-dht configuration file.
+# The apt-p2p configuration file.
#
# This is an ini-type configuration file, using sections identified by
# square brackets. Values are specified on a single line using the '='
PORT = 9977
# Directory to store the downloaded files in
-CACHE_DIR = /var/cache/apt-dht
+CACHE_DIR = /var/cache/apt-p2p
# Other directories containing packages to share with others
# WARNING: all files in these directories will be hashed and available
# It must be possile to do "from <DHT>.DHT import DHT" to get a class that
# implements the IDHT interface. There should also be a similarly named
# section below to specify the options for the DHT.
-DHT = apt_dht_Khashmir
+DHT = apt_p2p_Khashmir
# Whether to only run the DHT (for providing only a bootstrap node)
DHT-ONLY = no
-####################### apt_dht_Khashmir ############################
+####################### apt_p2p_Khashmir ############################
# This is the default (included) DHT to use.
-[apt_dht_Khashmir]
+[apt_p2p_Khashmir]
# To specify a different (UDP) port for the DHT to use.
# If not specified here, the PORT value in the DEFAULT section will be used.
#!/usr/bin/env python
-# Load apt-dht application
+# Load apt-p2p application
#
-# There are two ways apt-dht can be started:
-# 1. twistd -y apt-dht
+# There are two ways apt-p2p can be started:
+# 1. twistd -y apt-p2p
# - twistd will load this file and execute the app
# in 'application' variable
# 2. from command line
from twisted.python import usage, log
from twisted.web2 import channel
-from apt_dht.apt_dht_conf import config, version, DEFAULT_CONFIG_FILES
-from apt_dht.interfaces import IDHT
+from apt_p2p.apt_p2p_conf import config, version, DEFAULT_CONFIG_FILES
+from apt_p2p.interfaces import IDHT
config_file = ''
if __name__ == '__main__':
# Parse command line parameters when started on command line
- class AptDHTOptions(usage.Options):
+ class AptP2POptions(usage.Options):
optFlags = [
['help', 'h', 'Print this help message'],
]
['config-file', 'c', '', "Configuration file"],
['log-file', 'l', '-', "File to log to, - for stdout"],
]
- longdesc="apt-dht is a peer-to-peer downloader for apt users"
+ longdesc="apt-p2p is a peer-to-peer downloader for apt users"
def opt_version(self):
- print "apt-dht %s" % version.short()
+ print "apt-p2p %s" % version.short()
sys.exit(0)
- opts = AptDHTOptions()
+ opts = AptP2POptions()
try:
opts.parseOptions()
except usage.UsageError, ue:
uid,gid = None,None
log.msg('Starting application')
-application = service.Application("apt-dht", uid, gid)
+application = service.Application("apt-p2p", uid, gid)
#print service.IProcess(application).processName
-#service.IProcess(application).processName = 'apt-dht'
+#service.IProcess(application).processName = 'apt-p2p'
log.msg('Starting DHT')
DHT = __import__(config.get('DEFAULT', 'DHT')+'.DHT', globals(), locals(), ['DHT'])
if not config.getboolean('DEFAULT', 'DHT-only'):
log.msg('Starting main application server')
- from apt_dht.apt_dht import AptDHT
- myapp = AptDHT(myDHT)
+ from apt_p2p.apt_p2p import AptP2P
+ myapp = AptP2P(myDHT)
factory = myapp.getHTTPFactory()
s = strports.service('tcp:'+config.get('DEFAULT', 'port'), factory)
s.setServiceParent(application)
file = self.packages[f]
if f.split('/')[-1] == "Release":
self.addRelease(f, file)
- fake_uri='http://apt-dht'+f
+ fake_uri='http://apt-p2p'+f
fake_dirname = '/'.join(fake_uri.split('/')[:-1])
if f.endswith('Sources'):
deb_src_added = True
def setUp(self):
"""Initializes the cache with files found in the traditional apt location."""
- self.client = AptPackages(FilePath('/tmp/.apt-dht'), 300)
+ self.client = AptPackages(FilePath('/tmp/.apt-p2p'), 300)
# Find the largest index files that are for 'main'
self.packagesFile = os.popen('ls -Sr /var/lib/apt/lists/ | grep -E "_main_.*Packages$" | tail -n 1').read().rstrip('\n')
@ivar all_dirs: all the directories that have cached files in them
@type db: L{db.DB}
@ivar db: the database to use for tracking files and hashes
- @type manager: L{apt_dht.AptDHT}
+ @type manager: L{apt_p2p.AptP2P}
@ivar manager: the main program object to send requests to
@type scanning: C{list} of L{twisted.python.filepath.FilePath}
@ivar scanning: all the directories that are currectly being scanned or waiting to be scanned
@type other_dirs: C{list} of L{twisted.python.filepath.FilePath}
@param other_dirs: the other directories that have shared files in them
(optional, defaults to only using the cache directory)
- @type manager: L{apt_dht.AptDHT}
+ @type manager: L{apt_p2p.AptP2P}
@param manager: the main program object to send requests to
(optional, defaults to not calling back with cached files)
"""
client = None
def setUp(self):
- self.client = CacheManager(FilePath('/tmp/.apt-dht'))
+ self.client = CacheManager(FilePath('/tmp/.apt-p2p'))
def tearDown(self):
for p in self.pending_calls:
from twisted.trial import unittest
from zope.interface import implements
-from apt_dht_conf import version
+from apt_p2p_conf import version
class Peer(ClientFactory):
"""A manager for all HTTP requests to a single peer.
"""Get the common HTTP headers for all requests."""
headers = http_headers.Headers()
headers.setHeader('Host', self.host)
- headers.setHeader('User-Agent', 'apt-dht/%s (twisted/%s twisted.web2/%s)' %
+ headers.setHeader('User-Agent', 'apt-p2p/%s (twisted/%s twisted.web2/%s)' %
(version.short(), twisted_version.short(), web2_version.short()))
return headers
from twisted.web2 import static, http_headers, responsecode
from policies import ThrottlingFactory
-from apt_dht_Khashmir.bencode import bencode
+from apt_p2p_Khashmir.bencode import bencode
class FileDownloader(static.File):
"""Modified to make it suitable for apt requests.
freshness before being sent. Requests for unfound and stale files are
forwarded to the main program for downloading.
- @type manager: L{apt_dht.AptDHT}
+ @type manager: L{apt_p2p.AptP2P}
@ivar manager: the main program to query
"""
@ivar directory: the directory to check for cached files
@type db: L{db.DB}
@ivar db: the database to use for looking up files and hashes
- @type manager: L{apt_dht.AptDHT}
+ @type manager: L{apt_p2p.AptP2P}
@ivar manager: the main program object to send requests to
@type factory: L{twisted.web2.channel.HTTPFactory} or L{policies.ThrottlingFactory}
@ivar factory: the factory to use to server HTTP requests
@param directory: the directory to check for cached files
@type db: L{db.DB}
@param db: the database to use for looking up files and hashes
- @type manager: L{apt_dht.AptDHT}
+ @type manager: L{apt_p2p.AptP2P}
@param manager: the main program object to send requests to
"""
self.directory = directory
found = True
break
self.failUnless(found == True)
- h.set(hashType, 'c722df87e1acaa64b27aac4e174077afc3623540', '19')
+ h.set(hashType, '3bba0a5d97b7946ad2632002bf9caefe2cb18e00', '19')
h.new()
- h.update('apt-dht is the best')
- self.failUnless(h.hexdigest() == 'c722df87e1acaa64b27aac4e174077afc3623540')
+ h.update('apt-p2p is the best')
+ self.failUnless(h.hexdigest() == '3bba0a5d97b7946ad2632002bf9caefe2cb18e00')
self.failUnlessRaises(HashError, h.update, 'gfgf')
self.failUnless(h.verify() == True)
found = True
break
self.failUnless(found == True)
- h.set(hashType, '2a586bcd1befc5082c872dcd96a01403', '19')
+ h.set(hashType, '6b5abdd30d7ed80edd229f9071d8c23c', '19')
h.new()
- h.update('apt-dht is the best')
- self.failUnless(h.hexdigest() == '2a586bcd1befc5082c872dcd96a01403')
+ h.update('apt-p2p is the best')
+ self.failUnless(h.hexdigest() == '6b5abdd30d7ed80edd229f9071d8c23c')
self.failUnlessRaises(HashError, h.update, 'gfgf')
self.failUnless(h.verify() == True)
found = True
break
self.failUnless(found == True)
- h.set(hashType, '55b971f64d9772f733de03f23db39224f51a455cc5ad4c2db9d5740d2ab259a7', '19')
+ h.set(hashType, '47f2238a30a0340faa2bf01a9bdc42ba77b07b411cda1e24cd8d7b5c4b7d82a7', '19')
h.new()
- h.update('apt-dht is the best')
- self.failUnless(h.hexdigest() == '55b971f64d9772f733de03f23db39224f51a455cc5ad4c2db9d5740d2ab259a7')
+ h.update('apt-p2p is the best')
+ self.failUnless(h.hexdigest() == '47f2238a30a0340faa2bf01a9bdc42ba77b07b411cda1e24cd8d7b5c4b7d82a7')
self.failUnlessRaises(HashError, h.update, 'gfgf')
self.failUnless(h.verify() == True)
client = None
def setUp(self):
- self.client = MirrorManager(FilePath('/tmp/.apt-dht'), 300)
+ self.client = MirrorManager(FilePath('/tmp/.apt-p2p'), 300)
def test_extractPath(self):
"""Test extracting the site and base directory from various mirrors."""
-"""The main apt-dht modules.
+"""The main apt-p2p modules.
-To run apt-dht, you probably want to do something like::
+To run apt-p2p, you probably want to do something like::
- from apt_dht.apt_dht import AptDHT
- myapp = AptDHT(myDHT)
+ from apt_p2p.apt_p2p import AptP2P
+ myapp = AptP2P(myDHT)
where myDHT is a DHT that implements interfaces.IDHT.
Diagram of the interaction between the given modules::
+---------------+ +-----------------------------------+ +-------------
- | AptDHT | | DHT | | Internet
+ | AptP2P | | DHT | | Internet
| |--->|join DHT|----|--\
| |--->|loadConfig | | | Another
| |--->|getValue | | | Node
from twisted.python import log, failure
from twisted.python.filepath import FilePath
-from apt_dht_conf import config
+from apt_p2p_conf import config
from PeerManager import PeerManager
from HTTPServer import TopLevel
from MirrorManager import MirrorManager
download_dir = 'cache'
-class AptDHT:
+class AptP2P:
"""The main code object that does all of the work.
Contains all of the sub-components that do all the low-level work, and
@type dht: L{interfaces.IDHT}
@param dht: the DHT instance to use
"""
- log.msg('Initializing the main apt_dht application')
+ log.msg('Initializing the main apt_p2p application')
self.cache_dir = FilePath(config.get('DEFAULT', 'cache_dir'))
if not self.cache_dir.child(download_dir).exists():
self.cache_dir.child(download_dir).makedirs()
- self.db = DB(self.cache_dir.child('apt-dht.db'))
+ self.db = DB(self.cache_dir.child('apt-p2p.db'))
self.dht = dht
self.dht.loadConfig(config, config.get('DEFAULT', 'DHT'))
self.dht.join().addCallbacks(self.joinComplete, self.joinError)
def __str__(self):
return repr(self.message)
-version = versions.Version('apt-dht', 0, 0, 0)
+version = versions.Version('apt-p2p', 0, 0, 0)
# Set the home parameter
home = os.path.expandvars('${HOME}')
if not os.path.isdir(home):
home = os.path.abspath(os.path.dirname(sys.argv[0]))
-DEFAULT_CONFIG_FILES=['/etc/apt-dht/apt-dht.conf',
- home + '/.apt-dht/apt-dht.conf']
+DEFAULT_CONFIG_FILES=['/etc/apt-p2p/apt-p2p.conf',
+ home + '/.apt-p2p/apt-p2p.conf']
DEFAULTS = {
'PORT': '9977',
# Directory to store the downloaded files in
- 'CACHE_DIR': home + '/.apt-dht/cache',
+ 'CACHE_DIR': home + '/.apt-p2p/cache',
# Other directories containing packages to share with others
# WARNING: all files in these directories will be hashed and available
# Which DHT implementation to use.
# It must be possile to do "from <DHT>.DHT import DHT" to get a class that
# implements the IDHT interface.
- 'DHT': 'apt_dht_Khashmir',
+ 'DHT': 'apt_p2p_Khashmir',
# Whether to only run the DHT (for providing only a bootstrap node)
'DHT-ONLY': 'no',
'SPEW': 'yes',
}
-class AptDHTConfigParser(SafeConfigParser):
+class AptP2PConfigParser(SafeConfigParser):
"""Adds 'gettime' and 'getstringlist' to ConfigParser objects.
@ivar time_multipliers: the 'gettime' suffixes and the multipliers needed
return option.upper()
# Initialize the default config parameters
-config = AptDHTConfigParser(DEFAULTS)
+config = AptP2PConfigParser(DEFAULTS)
config.add_section(config.get('DEFAULT', 'DHT'))
for k in DHT_DEFAULTS:
config.set(config.get('DEFAULT', 'DHT'), k, DHT_DEFAULTS[k])
timeout = 5
db = FilePath('/tmp/khashmir.db')
hash = '\xca\xec\xb8\x0c\x00\xe7\x07\xf8~])\x8f\x9d\xe5_B\xff\x1a\xc4!'
- directory = FilePath('/tmp/apt-dht/')
- file = FilePath('/tmp/apt-dht/khashmir.test')
+ directory = FilePath('/tmp/apt-p2p/')
+ file = FilePath('/tmp/apt-p2p/khashmir.test')
testfile = 'tmp/khashmir.test'
- dirs = [FilePath('/tmp/apt-dht/top1'),
- FilePath('/tmp/apt-dht/top2/sub1'),
- FilePath('/tmp/apt-dht/top2/sub2/')]
+ dirs = [FilePath('/tmp/apt-p2p/top1'),
+ FilePath('/tmp/apt-p2p/top2/sub1'),
+ FilePath('/tmp/apt-p2p/top2/sub2/')]
def setUp(self):
if not self.file.parent().exists():
-"""Some interfaces that are used by the apt-dht classes."""
+"""Some interfaces that are used by the apt-p2p classes."""
from zope.interface import Interface
-"""Some utitlity functions for use in the apt-dht program.
+"""Some utitlity functions for use in the apt-p2p program.
@var isLocal: a compiled regular expression suitable for testing if an
IP address is from a known local or private range
from twisted.trial import unittest
from zope.interface import implements
-from apt_dht.interfaces import IDHT
+from apt_p2p.interfaces import IDHT
from khashmir import Khashmir
from bencode import bencode, bdecode
-khashmir_dir = 'apt-dht-Khashmir'
+khashmir_dir = 'apt-p2p-Khashmir'
class DHTError(Exception):
"""Represents errors that occur in the DHT."""
@type retrieved: C{dictionary}
@ivar retrieved: keys are the keys for which getValue requests are active,
values are list of the values returned so far
- @type config_parser: L{apt_dht.apt_dht_conf.AptDHTConfigParser}
+ @type config_parser: L{apt_p2p.apt_p2p_conf.AptP2PConfigParser}
@ivar config_parser: the configuration info for the main program
@type section: C{string}
@ivar section: the section of the configuration info that applies to the DHT
self.retrieved = {}
def loadConfig(self, config, section):
- """See L{apt_dht.interfaces.IDHT}."""
+ """See L{apt_p2p.interfaces.IDHT}."""
self.config_parser = config
self.section = section
self.config = {}
self.config[k] = self.config_parser.get(section, k)
def join(self):
- """See L{apt_dht.interfaces.IDHT}."""
+ """See L{apt_p2p.interfaces.IDHT}."""
if self.config is None:
raise DHTError, "configuration not loaded"
if self.joining:
return self.foundAddrs
def leave(self):
- """See L{apt_dht.interfaces.IDHT}."""
+ """See L{apt_p2p.interfaces.IDHT}."""
if self.config is None:
raise DHTError, "configuration not loaded"
return key
def getValue(self, key):
- """See L{apt_dht.interfaces.IDHT}."""
+ """See L{apt_p2p.interfaces.IDHT}."""
if self.config is None:
raise DHTError, "configuration not loaded"
if not self.joined:
del self.retrieving[key]
def storeValue(self, key, value):
- """See L{apt_dht.interfaces.IDHT}."""
+ """See L{apt_p2p.interfaces.IDHT}."""
if self.config is None:
raise DHTError, "configuration not loaded"
if not self.joined:
-"""The apt-dht implementation of the Khashmir DHT.
+"""The apt-p2p implementation of the Khashmir DHT.
These modules implement a modified Khashmir, which is a kademlia-like
Distributed Hash Table available at::
The protocol for the implementation's communication is described here::
- http://www.camrdale.org/apt-dht/protocol.html
+ http://www.camrdale.org/apt-p2p/protocol.html
To run the DHT you probably want to do something like::
- from apt_dht_Khashmir import DHT
+ from apt_p2p_Khashmir import DHT
myDHT = DHT.DHT()
myDHT.loadConfig(config, section)
myDHT.join()
## Copyright 2002-2003 Andrew Loewenstern, All Rights Reserved
# see LICENSE.txt for license information
-"""Some utitlity functions for use in apt-dht's khashmir DHT."""
+"""Some utitlity functions for use in apt-p2p's khashmir DHT."""
from twisted.trial import unittest
<!ENTITY dhsection "<manvolnum>5</manvolnum>">
<!ENTITY dhemail "<email>camrdale@gmail.com</email>">
<!ENTITY dhusername "Cameron Dale">
- <!ENTITY dhucpackage "<refentrytitle>apt-dht.conf</refentrytitle>">
- <!ENTITY dhpackage "apt-dht">
+ <!ENTITY dhucpackage "<refentrytitle>apt-p2p.conf</refentrytitle>">
+ <!ENTITY dhpackage "apt-p2p">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
<para>Configuration information for &dhpackage; is searched for in the following order, with later
entries overriding former ones:
<OrderedList>
- <ListItem><para>/etc/apt-dht/apt-dht.conf</para></ListItem>
- <ListItem><para>${HOME}/.apt-dht/apt-dht.conf</para></ListItem>
+ <ListItem><para>/etc/apt-p2p/apt-p2p.conf</para></ListItem>
+ <ListItem><para>${HOME}/.apt-p2p/apt-p2p.conf</para></ListItem>
<ListItem><para>the location specified by the config-file parameter</para></ListItem>
</OrderedList>
</para>
<term><option>CACHE_DIR = <replaceable>directory</replaceable></option></term>
<listitem>
<para>The <replaceable>directory</replaceable> to store the downloaded files in.
- (Default is ${HOME}/.apt-dht/cache.)</para>
+ (Default is ${HOME}/.apt-p2p/cache.)</para>
</listitem>
</varlistentry>
<varlistentry>
<para>The DHT implementation to use. It must be possile to do (in python)
``from <DHT>.DHT import DHT'' to get a class that implements the IDHT interface.
There should also be a similarly named section below to specify the options for the DHT.
- (Default is `apt_dht_Khashmir')</para>
+ (Default is `apt_p2p_Khashmir')</para>
</listitem>
</varlistentry>
<varlistentry>
</variablelist>
</refsect2>
<refsect2>
- <title>apt_dht_Khashmir</title>
+ <title>apt_p2p_Khashmir</title>
<variablelist>
<varlistentry>
<title>SEE ALSO</title>
<para>
- <citerefentry><refentrytitle>apt-dht</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>apt-p2p</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>
<refsect1>
<!ENTITY dhsection "<manvolnum>8</manvolnum>">
<!ENTITY dhemail "<email>camrdale@gmail.com</email>">
<!ENTITY dhusername "Cameron Dale">
- <!ENTITY dhucpackage "<refentrytitle>apt-dht</refentrytitle>">
- <!ENTITY dhpackage "apt-dht">
+ <!ENTITY dhucpackage "<refentrytitle>apt-p2p</refentrytitle>">
+ <!ENTITY dhpackage "apt-p2p">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
<refsynopsisdiv>
<para>Normally &dhpackage; is run from init.d using <command>twistd</command>, in which case no &dhpackage;
options can be specified on the command-line, and all configuration variables are
- read from the default config file locations of ${HOME}/.apt-dht.conf and /etc/apt-dht/apt-dht.conf.
+ read from the default config file locations of ${HOME}/.apt-p2p.conf and /etc/apt-p2p/apt-p2p.conf.
The command is then:</para>
<cmdsynopsis>
<command>twistd</command> <arg choice="Req">-y /path/to/&dhpackage;</arg> <arg rep="Repeat"><option>twistd options</option></arg>
<para>This manual page documents briefly the options available to the &dhpackage; command.</para>
<para><command>&dhpackage;</command> is a helper for downloading Debian packages files with APT.
- It will download any needed files from other Apt-DHT peers in a
+ It will download any needed files from other Apt-P2P peers in a
bittorrent-like manner, and so reduce the strain on the Debian mirrors.</para>
<para>In order for APT to send it's requests to &dhpackage;, the source.list entries must be modified to point to the
<term><option>-c <replaceable>filename</replaceable>,</option> <option>--configfile=<replaceable>filename</replaceable></option></term>
<listitem>
<para>the <replaceable>filename</replaceable> to use for the configuration file, options found in this
- file are combined with those in ${HOME}/.apt-dht/apt-dht.conf and /etc/apt-dht/apt-dht.conf
- (see <citerefentry><refentrytitle>apt-dht.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> for the format of the file)</para>
+ file are combined with those in ${HOME}/.apt-p2p/apt-p2p.conf and /etc/apt-p2p/apt-p2p.conf
+ (see <citerefentry><refentrytitle>apt-p2p.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> for the format of the file)</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<para>the <replaceable>filename</replaceable> to print log messages to,
or `-' to log to standard output, if not specified then
- /var/log/apt-dht.log will be used</para>
+ /var/log/apt-p2p.log will be used</para>
</listitem>
</varlistentry>
<varlistentry>
<title>SEE ALSO</title>
<para>
- <citerefentry><refentrytitle>apt-dht.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>apt-p2p.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>twistd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
-apt-dht (0.0.1~2.gbpc98e84) UNRELEASED; urgency=low
+apt-p2p (0.0.1~2.gbpc98e84) UNRELEASED; urgency=low
** SNAPSHOT build @c98e840e6f67e2971ffc26a698d76c09a919db91 **
-- Cameron Dale <camrdale@gmail.com> Wed, 20 Feb 2008 11:35:14 -0800
-apt-dht (0.0.0) unstable; urgency=low
+apt-p2p (0.0.0) unstable; urgency=low
* Initial release.
-Source: apt-dht
+Source: apt-p2p
Section: net
Priority: optional
Maintainer: Cameron Dale <camrdale@gmail.com>
-Homepage: http://www.camrdale.org/apt-dht.html
+Homepage: http://www.camrdale.org/apt-p2p.html
Standards-Version: 3.7.3
Build-Depends: debhelper (>= 5.0.37.2)
Build-Depends-Indep: python-dev, python-support (>= 0.5.4), docbook-to-man, python-debian (>= 0.1.4)
-Vcs-Git: git://git.camrdale.org/git/apt-dht.git
-Vcs-Browser: http://git.camrdale.org/?p=apt-dht.git;a=summary
+Vcs-Git: git://git.camrdale.org/git/apt-p2p.git
+Vcs-Browser: http://git.camrdale.org/?p=apt-p2p.git;a=summary
XS-Dm-Upload-Allowed: yes
-Package: apt-dht
+Package: apt-p2p
Architecture: all
Depends: ${python:Depends}, python-twisted-web2 (>= 0.2), adduser, python-debian (>= 0.1.4), python-apt (>= 0.6.20), python-pysqlite2 (>= 2.1)
-Provides: python-apt-dht, python-apt-dht-khashmir
+Provides: python-apt-p2p, python-apt-p2p-khashmir
Description: apt helper for peer-to-peer downloads of Debian packages
- Apt-DHT is a helper for downloading Debian packages files with APT.
- It will download any needed files from other Apt-DHT peers in a
+ Apt-P2P is a helper for downloading Debian packages files with APT.
+ It will download any needed files from other Apt-P2P peers in a
bittorrent-like manner, and so reduce the strain on the Debian mirrors.
.
- The Apt-DHT daemon runs automatically on startup and listens for
+ The Apt-P2P daemon runs automatically on startup and listens for
requests from APT for files, as well as maintaining membership in a
Distributed Hash Table (DHT). For any files which have a hash
available (most files), peers that have the file are looked for in the
DHT. The file can then be downloaded from them, using the uploading
bandwidth of other peers while reducing the demand on the Debian mirror
- network. However, if a package cannot be found on any peers, Apt-DHT
+ network. However, if a package cannot be found on any peers, Apt-P2P
will fall back to downloading from a mirror to ensure all packages are
downloaded. Once downloaded, the file is hash checked and added to the
DHT so that other peers can download it without the mirror.
-This is the Debian GNU/Linux packaged version of apt-dht
+This is the Debian GNU/Linux packaged version of apt-p2p
The package is written and maintained by Cameron Dale.
The original source can always be found at:
- http://ftp.debian.org/debian/pool/main/a/apt-dht/
+ http://ftp.debian.org/debian/pool/main/a/apt-p2p/
The project homepage is at
- http://www.camrdale.org/apt-dht.html
+ http://www.camrdale.org/apt-p2p.html
-Apt-dht is Copyright (C) 2008 Cameron Dale <camrdale@gmail.com>
+Apt-p2p is Copyright (C) 2008 Cameron Dale <camrdale@gmail.com>
This software is released under the terms of the GNU General Public License,
with the exceptions noted below.
On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.
-The module apt_dht_Khashmir is a modified version of the original khashmir,
+The module apt_p2p_Khashmir is a modified version of the original khashmir,
the source of which can be found at http://sourceforge.net/projects/khashmir.
It is covered by the following copyright and permission notice:
-# apt-dht configuration
+# apt-p2p configuration
## Filename to store pid of process
-#pidfile=/var/run/apt-dht/apt-dht.pid
+#pidfile=/var/run/apt-p2p/apt-p2p.pid
## Log file
-#logfile=/var/log/apt-dht.log
+#logfile=/var/log/apt-p2p.log
etc/default
etc/init.d
-usr/share/doc/apt-dht
+usr/share/doc/apt-p2p
usr/sbin
-var/cache/apt-dht
-var/lib/apt-dht
+var/cache/apt-p2p
+var/lib/apt-p2p
#!/bin/sh
### BEGIN INIT INFO
-# Provides: apt-dht
+# Provides: apt-p2p
# Required-Start: $network
# Required-Stop:
# Should-Start: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: apt helper for peer-to-peer downloads of Debian packages
-# Description: Apt-DHT is a helper for downloading Debian packages
+# Description: Apt-p2p is a helper for downloading Debian packages
# files with APT. It will download any needed files from
-# other Apt-DHT peers in a bittorrent-like manner, and so
+# other Apt-p2p peers in a bittorrent-like manner, and so
# reduce the strain on the Debian mirrors.
### END INIT INFO
-# /etc/init.d/apt-dht: start and stop the apt-dht daemon
+# /etc/init.d/apt-p2p: start and stop the apt-p2p daemon
PATH=/sbin:/bin:/usr/sbin:/usr/bin
-rundir=/var/run/apt-dht/
-pidfile=$rundir/apt-dht.pid
-logfile=/var/log/apt-dht.log
-application=/usr/sbin/apt-dht
+rundir=/var/run/apt-p2p/
+pidfile=$rundir/apt-p2p.pid
+logfile=/var/log/apt-p2p.log
+application=/usr/sbin/apt-p2p
twistd=/usr/bin/twistd
-user=aptdht
+user=aptp2p
group=nogroup
-[ -r /etc/default/apt-dht ] && . /etc/default/apt-dht
+[ -r /etc/default/apt-p2p ] && . /etc/default/apt-p2p
test -x $twistd || exit 0
test -r $application || exit 0
case "$1" in
start)
- echo -n "Starting apt-dht"
+ echo -n "Starting apt-p2p"
[ ! -d $rundir ] && mkdir $rundir
[ ! -f $logfile ] && touch $logfile
chown $user $rundir $logfile
;;
stop)
- echo -n "Stopping apt-dht"
+ echo -n "Stopping apt-p2p"
start-stop-daemon --stop --quiet --pidfile $pidfile
#
# Continue stopping until daemon finished or time over
;;
*)
- echo "Usage: /etc/init.d/apt-dht {start|stop|restart|force-reload}" >&2
+ echo "Usage: /etc/init.d/apt-p2p {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
-apt-dht.conf etc/apt-dht
+apt-p2p.conf etc/apt-p2p
-debian/apt-dht.8
-debian/apt-dht.conf.5
+debian/apt-p2p.8
+debian/apt-p2p.conf.5
#! /bin/sh
-# postinst script for apt-dht
+# postinst script for apt-p2p
#
# see: dh_installdeb(1)
case "$1" in
configure)
- if ! getent passwd aptdht >/dev/null; then
+ if ! getent passwd aptp2p >/dev/null; then
adduser --quiet --system --no-create-home \
- --home /var/cache/apt-dht --disabled-password \
+ --home /var/cache/apt-p2p --disabled-password \
--disabled-login --shell /bin/false --ingroup nogroup \
- aptdht
+ aptp2p
fi
- touch /var/log/apt-dht.log
- chown aptdht:adm /var/log/apt-dht.log
- mkdir -p /var/cache/apt-dht
- chown -R aptdht:adm /var/cache/apt-dht
+ touch /var/log/apt-p2p.log
+ chown aptp2p:adm /var/log/apt-p2p.log
+ mkdir -p /var/cache/apt-p2p
+ chown -R aptp2p:adm /var/cache/apt-p2p
;;
abort-upgrade|abort-remove|abort-deconfigure)
#! /bin/sh
-# postrm script for apt-dht
+# postrm script for apt-p2p
#
# see: dh_installdeb(1)
if test "$1" = "purge"; then
# Remove the logs
- rm -rf /var/log/apt-dht.log*
+ rm -rf /var/log/apt-p2p.log*
- echo Purging apt-dht cache directory
- rm -rf /var/cache/apt-dht
+ echo Purging apt-p2p cache directory
+ rm -rf /var/cache/apt-p2p
- if id aptdht >/dev/null; then
- deluser aptdht
+ if id aptp2p >/dev/null; then
+ deluser aptp2p
fi
fi
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
-PACKAGE="apt-dht"
+PACKAGE="apt-p2p"
dpkg --listfiles $PACKAGE |
awk '$0~/\.py$/ {print $0"c\n" $0"o"}' |
PYTHON_VERSION=$(shell /usr/bin/python -V 2>&1 | /usr/bin/perl -le 'print "$$1.$$2" if <> =~m/^Python\s+(\d+)\.(\d+)(\.\d+)*/')
-build-stamp: apt-dht.8 apt-dht.conf.5
+build-stamp: apt-p2p.8 apt-p2p.conf.5
dh_testdir
touch build-stamp
clean:
dh_testdir
dh_testroot
- rm -rf build/ apt_dht/*.pyc apt_dht_Khashmir/*.pyc *.pyc
+ rm -rf build/ apt_p2p/*.pyc apt_p2p_Khashmir/*.pyc *.pyc
rm -f debian/*.[58]
rm -f build-stamp
dh_clean
dh_clean -k
dh_installdirs
- ./setup.py install --prefix=$(CURDIR)/debian/apt-dht/usr \
- --install-lib=$(CURDIR)/debian/apt-dht/usr/share/python-support/apt-dht \
- --install-scripts=$(CURDIR)/debian/apt-dht/usr/sbin
+ ./setup.py install --prefix=$(CURDIR)/debian/apt-p2p/usr \
+ --install-lib=$(CURDIR)/debian/apt-p2p/usr/share/python-support/apt-p2p \
+ --install-scripts=$(CURDIR)/debian/apt-p2p/usr/sbin
# Remove the generated .pyc files
- ( cd debian/apt-dht/usr/share/python-support/apt-dht/apt_dht_Khashmir && \
+ ( cd debian/apt-p2p/usr/share/python-support/apt-p2p/apt_p2p_Khashmir && \
rm -f *.pyc && \
- cd ../apt_dht && \
+ cd ../apt_p2p && \
rm -f *.pyc )
# Build architecture-independent files here.
dh_installman
# Remove the .py from the end of each of these
- mv debian/apt-dht/usr/sbin/apt-dht.py debian/apt-dht/usr/sbin/apt-dht
+ mv debian/apt-p2p/usr/sbin/apt-p2p.py debian/apt-p2p/usr/sbin/apt-p2p
dh_installchangelogs
dh_install
# The list of objects to document. Objects can be named using
# dotted names, module filenames, or package directory names.
# Alases for this option include "objects" and "values".
-modules: apt_dht apt_dht_Khashmir test.py
+modules: apt_p2p apt_p2p_Khashmir test.py
# The type of output that should be generated. Should be one
# of: html, text, latex, dvi, ps, pdf.
### Output options
# The documented project's name.
-name: Apt-DHT
+name: Apt-P2P
# The CSS stylesheet for HTML output. Can be the name of a builtin
# stylesheet, or the name of a file.
css: white
# The documented project's URL.
-url: http://www.camrdale.org/apt-dht.html
+url: http://www.camrdale.org/apt-p2p.html
# HTML code for the project link in the navigation bar. If left
# unspecified, the project link will be generated based on the
kileversion=1.9.2
lastDocument=motivation.tex
masterDocument=
-name=apt-dht-motivation
+name=apt-p2p-motivation
pkg_extIsRegExp=false
pkg_extensions=.cls .sty .dtx
src_extIsRegExp=false
line=225
open=true
-[item:apt-dht-motivation.kilepr]
+[item:apt-p2p-motivation.kilepr]
archive=true
column=0
encoding=
A sample implementation has been created that functions as described
in section \ref{opportunity}. This software, called
-\texttt{apt-dht}, interacts with the \texttt{apt} tool found in most
+\texttt{apt-p2p}, interacts with the \texttt{apt} tool found in most
Debian-based Linux distributions. Apt uses SHA1 hashes to
verify most downloaded files, including the large index files that
contain the hashes of the individual packages. We chose this
\begin{figure}
\centering
-\includegraphics[width=\columnwidth]{apt_dht_simulation-size_CDF.eps}
+\includegraphics[width=\columnwidth]{apt_p2p_simulation-size_CDF.eps}
\caption{The CDF of the size of packages in a Debian system, both
for the actual size and adjusted size based on the popularity of
the package.}
del data
setup(
- name = "apt-dht",
+ name = "apt-p2p",
version = c.full_version,
author = "Cameron Dale",
author_email = "<camrdale@gmail.com>",
- url = "http://www.camrdale.org/apt-dht.html",
+ url = "http://www.camrdale.org/apt-p2p.html",
license = "GPL",
- packages = ["apt_dht", "apt_dht_Khashmir"],
+ packages = ["apt_p2p", "apt_p2p_Khashmir"],
- scripts = ['apt-dht.py']
+ scripts = ['apt-p2p.py']
)
#!/usr/bin/env python
-"""Automated tests of the apt-dht functionality.
+"""Automated tests of the apt-p2p functionality.
This script runs several automatic tests of some of the functionality in
-the apt-dht program.
+the apt-p2p program.
@type tests: C{dictionary}
@var tests: all of the tests that can be run.
The bootstrap nodes keys are integers, which must be in the range 1-9.
The values are the dictionary of string formatting values for creating
- the apt-dht configuration file (see L{apt_dht_conf_template} below).
+ the apt-p2p configuration file (see L{apt_p2p_conf_template} below).
The downloaders keys are also integers in the range 1-99. The values are
- the dictionary of string formatting values for creating the apt-dht
- configuration file (see L{apt_dht_conf_template} below).
+ the dictionary of string formatting values for creating the apt-p2p
+ configuration file (see L{apt_p2p_conf_template} below).
The apt-get commands' list elements are tuples with 2 elements: the
downloader to run the command on, and the list of command-line
}
"""
-apt_dht_conf_template = """
+apt_p2p_conf_template = """
[DEFAULT]
# Port to listen on for all requests (TCP and UDP)
# Which DHT implementation to use.
# It must be possile to do "from <DHT>.DHT import DHT" to get a class that
# implements the IDHT interface.
-DHT = apt_dht_Khashmir
+DHT = apt_p2p_Khashmir
# Whether to only run the DHT (for providing only a bootstrap node)
DHT-ONLY = %(DHT-ONLY)s
-[apt_dht_Khashmir]
+[apt_p2p_Khashmir]
# bootstrap nodes to contact to join the DHT
BOOTSTRAP = %(BOOTSTRAP)s
@param num_down: the number of the downloader to use
@type options: C{dictionary}
@param options: the dictionary of string formatting values for creating
- the apt-dht configuration file (see L{apt_dht_conf_template} above).
+ the apt-p2p configuration file (see L{apt_p2p_conf_template} above).
(optional, defaults to only using the default arguments)
@type mirror: C{string}
@param mirror: the Debian mirror to use
for k in options:
defaults[k] = options[k]
- f = open(join([downloader_dir, 'apt-dht.conf']), 'w')
- f.write(apt_dht_conf_template % defaults)
+ f = open(join([downloader_dir, 'apt-p2p.conf']), 'w')
+ f.write(apt_p2p_conf_template % defaults)
f.close()
- pid = start('python', [join([sys.path[0], 'apt-dht.py']),
- '--config-file=' + join([downloader_dir, 'apt-dht.conf']),
- '--log-file=' + join([downloader_dir, 'apt-dht.log']),],
+ pid = start('python', [join([sys.path[0], 'apt-p2p.py']),
+ '--config-file=' + join([downloader_dir, 'apt-p2p.conf']),
+ '--log-file=' + join([downloader_dir, 'apt-p2p.log']),],
downloader_dir)
return pid
def start_bootstrap(bootstrap_addresses, num_boot, options = [], clean = True):
"""Initialize a new bootstrap node process.
- The default arguments specified to the apt-dht invocation are
+ The default arguments specified to the apt-p2p invocation are
the state file and port to use. Any additional arguments needed
should be specified by L{options}.
for k in options:
defaults[k] = options[k]
- f = open(join([bootstrap_dir, 'apt-dht.conf']), 'w')
- f.write(apt_dht_conf_template % defaults)
+ f = open(join([bootstrap_dir, 'apt-p2p.conf']), 'w')
+ f.write(apt_p2p_conf_template % defaults)
f.close()
- pid = start('python', [join([sys.path[0], 'apt-dht.py']),
- '--config-file=' + join([bootstrap_dir, 'apt-dht.conf']),
- '--log-file=' + join([bootstrap_dir, 'apt-dht.log']),],
+ pid = start('python', [join([sys.path[0], 'apt-p2p.py']),
+ '--config-file=' + join([bootstrap_dir, 'apt-p2p.conf']),
+ '--log-file=' + join([bootstrap_dir, 'apt-p2p.log']),],
bootstrap_dir)
return pid