Rev395, Trackers_file parameter that allows to specify dynamically loaded bottstrap trackers
This commit is contained in:
parent
cf5a4f902b
commit
fa37f58982
2 changed files with 15 additions and 9 deletions
|
@ -8,7 +8,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.3.2"
|
||||
self.rev = 394
|
||||
self.rev = 395
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.createParser()
|
||||
|
@ -132,6 +132,7 @@ class Config(object):
|
|||
self.parser.add_argument('--proxy', help='Socks proxy address', metavar='ip:port')
|
||||
self.parser.add_argument('--ip_external', help='Set reported external ip (tested on start if None)', metavar='ip')
|
||||
self.parser.add_argument('--trackers', help='Bootstraping torrent trackers', default=trackers, metavar='protocol://address', nargs='*')
|
||||
self.parser.add_argument('--trackers_file', help='Load torrent trackers dynamically from a file', default=False, metavar='path')
|
||||
self.parser.add_argument('--use_openssl', help='Use OpenSSL liblary for speedup',
|
||||
type='bool', choices=[True, False], default=use_openssl)
|
||||
self.parser.add_argument('--disable_encryption', help='Disable connection encryption', action='store_true')
|
||||
|
@ -151,7 +152,13 @@ class Config(object):
|
|||
|
||||
return self.parser
|
||||
|
||||
# Find arguments specificed for current action
|
||||
def loadTrackersFile(self):
|
||||
self.trackers = []
|
||||
for tracker in open(self.trackers_file):
|
||||
if "://" in tracker:
|
||||
self.trackers.append(tracker.strip())
|
||||
|
||||
# Find arguments specified for current action
|
||||
def getActionArguments(self):
|
||||
back = {}
|
||||
arguments = self.parser._subparsers._group_actions[0].choices[self.action]._actions[1:] # First is --version
|
||||
|
@ -247,7 +254,7 @@ class Config(object):
|
|||
if section != "global": # If not global prefix key with section
|
||||
key = section + "_" + key
|
||||
if val:
|
||||
for line in val.strip().split("\n"): # Allow multi-line values
|
||||
for line in val.strip().split("\n"): # Allow multi-line values
|
||||
argv.insert(1, line)
|
||||
argv.insert(1, "--%s" % key)
|
||||
return argv
|
||||
|
|
|
@ -173,6 +173,8 @@ class FileServer(ConnectionServer):
|
|||
first_announce = True # First start
|
||||
while 1:
|
||||
# Sites healthcare
|
||||
if config.trackers_file:
|
||||
config.loadTrackersFile()
|
||||
for address, site in self.sites.items():
|
||||
if site.settings["serving"]:
|
||||
if first_announce: # Announce to all trackers on startup
|
||||
|
@ -202,17 +204,14 @@ class FileServer(ConnectionServer):
|
|||
# Find new peers
|
||||
for tracker_i in range(len(config.trackers)):
|
||||
time.sleep(60 * 20 / len(config.trackers)) # Query all trackers one-by-one in 20 minutes evenly distributed
|
||||
|
||||
if config.trackers_file:
|
||||
config.loadTrackersFile()
|
||||
for address, site in self.sites.items():
|
||||
site.announce(num = 1, pex = False)
|
||||
site.announce(num=1, pex=False)
|
||||
time.sleep(2)
|
||||
|
||||
first_announce = False
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Detects if computer back from wakeup
|
||||
def wakeupWatcher(self):
|
||||
last_time = time.time()
|
||||
|
|
Loading…
Reference in a new issue