diff options
author | Jeffrey C. Ollie <jeff@ocjtech.us> | 2008-09-17 21:09:12 -0500 |
---|---|---|
committer | Jeffrey C. Ollie <jeff@ocjtech.us> | 2008-09-17 21:09:12 -0500 |
commit | 1b6d4b63008360b8117a791c4da73400fe0a38e6 (patch) | |
tree | 62ba0aec9f87960c2d05c2f986f2062d619d8ebb | |
parent | c2ab0c77c4faa365dd1d27c9a6849e0ff875533c (diff) | |
download | nohgooee-1b6d4b63008360b8117a791c4da73400fe0a38e6.tar.gz nohgooee-1b6d4b63008360b8117a791c4da73400fe0a38e6.tar.xz nohgooee-1b6d4b63008360b8117a791c4da73400fe0a38e6.zip |
Switch configs to twisted-style options parsing.
-rw-r--r-- | NohGooee/config.py | 242 |
1 files changed, 126 insertions, 116 deletions
diff --git a/NohGooee/config.py b/NohGooee/config.py index 28c61dd..fe540ab 100644 --- a/NohGooee/config.py +++ b/NohGooee/config.py @@ -11,123 +11,133 @@ # License. from lxml import etree +from twisted.python import usage -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) - - } - - +class NohgooeeOptions(usage.Options): + + optFlags = [ + ['allowed_controls', + None, + _("allow special keys in torrents in the allowed_dir to affect " + "tracker access")], + + + ['allow_get', None, + _("use with allowed_dir; adds a /file?hash={hash} url that " + "allows users to download the torrent file"), + ], + + ['close_with_rst', None, + _("close connections with RST and avoid the TCP TIME_WAIT state")], + + ['keep_dead', None, + _("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")], + + ['log_nat_checks', None, + _("whether to add entries to the log for nat-check results")], + + ] + + optParameters = [ + + ['allowed_dir', + None, + '', + _("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")], + + ['bind', None, + '', + _("ip to bind to locally")], + + ['dfile', None, + '/tmp/dfile.txt', + _("file to store recent downloader info in")], + + ['favicon', None, + '', + _("file containing x-icon data to return when browser requests " + "favicon.ico")], + + ['infopage_redirect', None, + '', + _("a URL to redirect the info page to")], + + ['max_give', None, + 200, + _("maximum number of peers to give with any one request")], + + ['min_time_between_cache_refreshes', None, + 600.0, + _("minimum time in seconds before a cache is considered stale " + "and is flushed")], + + ['min_time_between_log_flushes', None, + 3.0, + _("minimum time it must have been since the last flush to do " + "another one")], + + ['nat_check', None, + 3, + _("how many times to check if a downloader is behind a NAT " + "(0 = don't check)")], + + ['only_local_override_ip', None, + 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', None, + 60, + _("how often to rescan the torrent directory, in seconds")], + + ['port', None, + 6969, + _("Port to listen on.")], + + ['reannounce_interval', None, + 30 * 60, + _("seconds downloaders should wait between reannouncements")], + + ['response_size', None, + 50, + _("default number of peers to send an info message to if the " + "client does not specify a number")], + + ['save_dfile_interval', None, + 5 * 60, + _("seconds between saving dfile")], + + ['scrape_allowed', None, + 'full', + _("scrape access allowed (can be none, specific or full)")], + + ['show_infopage', None, + True, + _("whether to display an info page when the tracker's root dir " + "is loaded")], + + ['show_names', None, + True, + _("whether to display names from allowed dir")], + + ['socket_timeout', None, + 15, + _("timeout for closing connections")], + + ['timeout_check_interval', None, + 5, + _("time to wait between checking if any connections have timed out")], + + ['timeout_downloaders_interval', None, + 45 * 60, + _("seconds between expiring downloaders")] + ] |