# for uploads to other peers. If a port is not specified for the DHT, it will also
# use this UDP port to listen for DHT requests.
PORT = 9977
-
+
+# The rate to limit sending data to peers to, in KBytes/sec.
+# Set this to 0 to not limit the upload bandwidth.
+UPLOAD_LIMIT = 0
+
# Directory to store the downloaded files in
CACHE_DIR = /var/cache/apt-p2p
# for everybody to download
# OTHER_DIRS =
-# Whether it's OK to use an IP addres from a known local/private range
+# Whether it's OK to use an IP address from a known local/private range
LOCAL_OK = no
# Unload the packages cache after an interval of inactivity this long.
KEY_REFRESH = 57m
# Which DHT implementation to use.
-# It must be possile to do "from <DHT>.DHT import DHT" to get a class that
+# It must be possible 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_p2p_Khashmir
addSlash = True
- def __init__(self, directory, db, manager):
+ def __init__(self, directory, db, manager, uploadLimit):
"""Initialize the instance.
@type directory: L{twisted.python.filepath.FilePath}
self.directory = directory
self.db = db
self.manager = manager
+ self.uploadLimit = None
+ if uploadLimit > 0:
+ self.uploadLimit = int(uploadLimit*1024)
self.factory = None
def getHTTPFactory(self):
self.factory = channel.HTTPFactory(server.Site(self),
**{'maxPipeline': 10,
'betweenRequestsTimeOut': 60})
- self.factory = ThrottlingFactory(self.factory, writeLimit = 30*1024)
+ self.factory = ThrottlingFactory(self.factory, writeLimit = self.uploadLimit)
self.factory.protocol = UploadThrottlingProtocol
return self.factory
"""
log.msg('Initializing the main apt_p2p application')
self.dhtClass = dhtClass
- self.cache_dir = FilePath(config.get('DEFAULT', 'cache_dir'))
+ 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-p2p.db'))
self.dht = dhtClass()
self.dht.loadConfig(config, config.get('DEFAULT', 'DHT'))
self.dht.join().addCallbacks(self.joinComplete, self.joinError)
- self.http_server = TopLevel(self.cache_dir.child(download_dir), self.db, self)
+ self.http_server = TopLevel(self.cache_dir.child(download_dir), self.db, self,
+ config.getint('DEFAULT', 'UPLOAD_LIMIT'))
self.getHTTPFactory = self.http_server.getHTTPFactory
self.peers = PeerManager()
self.mirrors = MirrorManager(self.cache_dir, config.gettime('DEFAULT', 'UNLOAD_PACKAGES_CACHE'))
# Port to listen on for all requests (TCP and UDP)
'PORT': '9977',
+ # The rate to limit sending data to peers to, in KBytes/sec.
+ # Set this to 0 to not limit the upload bandwidth.
+ 'UPLOAD_LIMIT': '0',
+
# Directory to store the downloaded files in
'CACHE_DIR': home + '/.apt-p2p/cache',
# User name to try and run as
'USERNAME': '',
- # Whether it's OK to use an IP addres from a known local/private range
+ # Whether it's OK to use an IP address from a known local/private range
'LOCAL_OK': 'no',
# Unload the packages cache after an interval of inactivity this long.
'KEY_REFRESH': '57m',
# Which DHT implementation to use.
- # It must be possile to do "from <DHT>.DHT import DHT" to get a class that
+ # It must be possible to do "from <DHT>.DHT import DHT" to get a class that
# implements the IDHT interface.
'DHT': 'apt_p2p_Khashmir',
(Default is 9977.)</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>UPLOAD_LIMIT = <replaceable>speed</replaceable></option></term>
+ <listitem>
+ <para>The <replaceable>speed</replaceable> to limit sending data to peers to, in KBytes/sec.
+ Set this to 0 to not limit the upload bandwidth.
+ (Default is 0)</para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>CACHE_DIR = <replaceable>directory</replaceable></option></term>
<listitem>
# Port to listen on for all requests (TCP and UDP)
PORT = %(PORT)s
+# The rate to limit sending data to peers to, in KBytes/sec.
+# Set this to 0 to not limit the upload bandwidth.
+UPLOAD_LIMIT = 100
+
# Directory to store the downloaded files in
CACHE_DIR = %(CACHE_DIR)s