summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey C. Ollie <jeff@ocjtech.us>2008-08-22 21:28:42 -0500
committerJeffrey C. Ollie <jeff@ocjtech.us>2008-08-22 21:28:42 -0500
commit4f43d7105763730b934a93ce54765062c9307957 (patch)
treeca71936bd8a29c627dcc326c4975b7d075917ec8
parent397a78b63a6a6a39feb80507fdac00508e83db15 (diff)
downloadnohgooee-4f43d7105763730b934a93ce54765062c9307957.tar.gz
nohgooee-4f43d7105763730b934a93ce54765062c9307957.tar.xz
nohgooee-4f43d7105763730b934a93ce54765062c9307957.zip
Clean up tracker configuration a bit.
-rw-r--r--NohGooee/config.py138
-rw-r--r--NohGooee/track.py76
-rwxr-xr-xnohgooee-tracker.tac4
3 files changed, 142 insertions, 76 deletions
diff --git a/NohGooee/config.py b/NohGooee/config.py
new file mode 100644
index 0000000..28c61dd
--- /dev/null
+++ b/NohGooee/config.py
@@ -0,0 +1,138 @@
+# -*- mode: python; coding: utf-8 -*-
+
+# The contents of this file are subject to the BitTorrent Open Source License
+# Version 1.1 (the License). You may not copy or use this file, in either
+# source code or executable form, except in compliance with the License. You
+# may obtain a copy of the License at http://www.bittorrent.com/license/.
+#
+# Software distributed under the License is distributed on an AS IS basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+
+from lxml import etree
+
+config = {
+ 'allowed_controls': (False,
+ _("allow special keys in torrents in the allowed_dir to affect "
+ "tracker access"),
+ bool),
+
+ 'allowed_dir': ('',
+ _("only allow downloads for .torrents in this dir (and recursively in "
+ "subdirectories of directories that have no .torrent files "
+ "themselves). If set, torrents in this directory show up on "
+ "infopage/scrape whether they have peers or not")),
+
+ 'allow_get': (False,
+ _("use with allowed_dir; adds a /file?hash={hash} url that "
+ "allows users to download the torrent file"),
+ bool),
+
+ 'bind': ('',
+ _("ip to bind to locally")),
+
+ 'close_with_rst': (False,
+ _("close connections with RST and avoid the TCP TIME_WAIT state"),
+ bool),
+
+ 'dfile': ('/tmp/dfile.txt',
+ _("file to store recent downloader info in")),
+
+
+ 'favicon': ('',
+ _("file containing x-icon data to return when browser requests "
+ "favicon.ico")),
+
+ 'infopage_redirect': ('',
+ _("a URL to redirect the info page to")),
+
+ 'keep_dead': (False,
+ _("keep dead torrents after they expire (so they still show up on your "
+ "/scrape and web page). Only matters if allowed_dir is not set"),
+ bool),
+
+ 'log_nat_checks': (False,
+ _("whether to add entries to the log for nat-check results"),
+ bool),
+
+ 'max_give': (200,
+ _("maximum number of peers to give with any one request")),
+
+ 'min_time_between_cache_refreshes': (600.0,
+ _("minimum time in seconds before a cache is considered stale "
+ "and is flushed"),
+ float),
+
+ 'min_time_between_log_flushes': (3.0,
+ _("minimum time it must have been since the last flush to do "
+ "another one"),
+ float),
+
+ 'nat_check': (3,
+ _("how many times to check if a downloader is behind a NAT "
+ "(0 = don't check)"),
+ int),
+
+ 'only_local_override_ip': (2,
+ _("ignore the ip GET parameter from machines which aren't on "
+ "local network IPs (0 = never, 1 = always, 2 = ignore if NAT "
+ "checking is not enabled). HTTP proxy headers giving address "
+ "of original client are treated the same as --ip.")),
+
+ 'parse_dir_interval': (60,
+ _("how often to rescan the torrent directory, in seconds"),
+ float),
+
+ 'port': (6969,
+ _("Port to listen on."),
+ int),
+
+ 'reannounce_interval': (30 * 60,
+ _("seconds downloaders should wait between reannouncements"),
+ int),
+
+ 'response_size': (50,
+ _("default number of peers to send an info message to if the "
+ "client does not specify a number"),
+ int),
+
+ 'save_dfile_interval': (5 * 60,
+ _("seconds between saving dfile"),
+ int),
+
+ 'scrape_allowed': ('full',
+ _("scrape access allowed (can be none, specific or full)")),
+
+ 'show_infopage': (True,
+ _("whether to display an info page when the tracker's root dir "
+ "is loaded"),
+ bool),
+
+ 'show_names': (True,
+ _("whether to display names from allowed dir"),
+ bool),
+
+ 'socket_timeout': (15,
+ _("timeout for closing connections"),
+ int),
+
+ 'timeout_check_interval': (5,
+ _("time to wait between checking if any connections have timed out"),
+ int),
+
+ 'timeout_downloaders_interval': (45 * 60,
+ _("seconds between expiring downloaders"),
+ int)
+
+ }
+
+
+
+
+
+
+
+
+
+
diff --git a/NohGooee/track.py b/NohGooee/track.py
index a8c1fa7..6511e19 100644
--- a/NohGooee/track.py
+++ b/NohGooee/track.py
@@ -22,84 +22,12 @@ from twisted.web.resource import Resource
from twisted.internet import reactor
from twisted.python import log
-from NohGooee.parseargs import parseargs, formatDefinitions
from NohGooee.parsedir import parsedir
from NohGooee.NatCheck import NatCheck
from NohGooee.bencode import bencode, bdecode, Bencached
from NohGooee.zurllib import quote, unquote
from NohGooee import version
-
-defaults = [
- ('port', 80,
- _("Port to listen on.")),
- ('dfile', '/tmp/dfile.txt',
- _("file to store recent downloader info in")),
- ('bind', '',
- _("ip to bind to locally")),
- ('socket_timeout', 15,
- _("timeout for closing connections")),
- ('close_with_rst', 0,
- _("close connections with RST and avoid the TCP TIME_WAIT state")),
- ('save_dfile_interval', 5 * 60,
- _("seconds between saving dfile")),
- ('timeout_downloaders_interval', 45 * 60,
- _("seconds between expiring downloaders")),
- ('reannounce_interval', 30 * 60,
- _("seconds downloaders should wait between reannouncements")),
- ('response_size', 50,
- _("default number of peers to send an info message to if the "
- "client does not specify a number")),
- ('timeout_check_interval', 5,
- _("time to wait between checking if any connections have timed out")),
- ('nat_check', 3,
- _("how many times to check if a downloader is behind a NAT "
- "(0 = don't check)")),
- ('log_nat_checks', 0,
- _("whether to add entries to the log for nat-check results")),
- ('min_time_between_log_flushes', 3.0,
- _("minimum time it must have been since the last flush to do "
- "another one")),
- ('min_time_between_cache_refreshes', 600.0,
- _("minimum time in seconds before a cache is considered stale "
- "and is flushed")),
- ('allowed_dir', '',
- _("only allow downloads for .torrents in this dir (and recursively in "
- "subdirectories of directories that have no .torrent files "
- "themselves). If set, torrents in this directory show up on "
- "infopage/scrape whether they have peers or not")),
- ('parse_dir_interval', 60,
- _("how often to rescan the torrent directory, in seconds")),
- ('allowed_controls', 0,
- _("allow special keys in torrents in the allowed_dir to affect "
- "tracker access")),
- ('show_infopage', 1,
- _("whether to display an info page when the tracker's root dir "
- "is loaded")),
- ('infopage_redirect', '',
- _("a URL to redirect the info page to")),
- ('show_names', 1,
- _("whether to display names from allowed dir")),
- ('favicon', '',
- _("file containing x-icon data to return when browser requests "
- "favicon.ico")),
- ('only_local_override_ip', 2,
- _("ignore the ip GET parameter from machines which aren't on "
- "local network IPs (0 = never, 1 = always, 2 = ignore if NAT "
- "checking is not enabled). HTTP proxy headers giving address "
- "of original client are treated the same as --ip.")),
- ('allow_get', 0,
- _("use with allowed_dir; adds a /file?hash={hash} url that "
- "allows users to download the torrent file")),
- ('keep_dead', 0,
- _("keep dead torrents after they expire (so they still show up on your "
- "/scrape and web page). Only matters if allowed_dir is not set")),
- ('scrape_allowed', 'full',
- _("scrape access allowed (can be none, specific or full)")),
- ('max_give', 200,
- _("maximum number of peers to give with any one request")),
- ]
-
def statefiletemplate(x):
if type(x) != DictType:
raise ValueError
@@ -220,9 +148,7 @@ def is_local_ip(ip):
class Tracker(object):
- def __init__(self):
-
- config, files = parseargs([], defaults, 0, 0)
+ def __init__(self, config):
self.config = config
self.response_size = config['response_size']
self.max_give = config['max_give']
diff --git a/nohgooee-tracker.tac b/nohgooee-tracker.tac
index e957433..1e032b3 100755
--- a/nohgooee-tracker.tac
+++ b/nohgooee-tracker.tac
@@ -16,11 +16,13 @@ from NohGooee.platform import install_translation
install_translation()
from NohGooee.track import Tracker, InfoPage, Scrape, File, Announce, FavIcon
+from NohGooee.config import config
from twisted.application import internet, service
from twisted.web import static, server
+from twisted.python import usage
-tracker = Tracker()
+tracker = Tracker(config)
root = InfoPage(tracker)
root.putChild('scrape', Scrape(tracker))
root.putChild('file', File(tracker))