Support multiple trackers_file argument
This commit is contained in:
parent
b9b317e213
commit
b22343f65c
3 changed files with 17 additions and 16 deletions
|
@ -109,7 +109,7 @@ class ConfigStorage extends Class
|
||||||
section.items.push
|
section.items.push
|
||||||
title: "Trackers files"
|
title: "Trackers files"
|
||||||
key: "trackers_file"
|
key: "trackers_file"
|
||||||
type: "text"
|
type: "textarea"
|
||||||
description: "Load additional list of torrent trackers dynamically, from a file"
|
description: "Load additional list of torrent trackers dynamically, from a file"
|
||||||
placeholder: "Eg.: data/trackers.json"
|
placeholder: "Eg.: data/trackers.json"
|
||||||
value_pos: "fullwidth"
|
value_pos: "fullwidth"
|
||||||
|
|
|
@ -1430,7 +1430,7 @@
|
||||||
section.items.push({
|
section.items.push({
|
||||||
title: "Trackers files",
|
title: "Trackers files",
|
||||||
key: "trackers_file",
|
key: "trackers_file",
|
||||||
type: "text",
|
type: "textarea",
|
||||||
description: "Load additional list of torrent trackers dynamically, from a file",
|
description: "Load additional list of torrent trackers dynamically, from a file",
|
||||||
placeholder: "Eg.: data/trackers.json",
|
placeholder: "Eg.: data/trackers.json",
|
||||||
value_pos: "fullwidth"
|
value_pos: "fullwidth"
|
||||||
|
|
|
@ -250,7 +250,7 @@ class Config(object):
|
||||||
self.parser.add_argument('--proxy', help='Socks proxy address', metavar='ip:port')
|
self.parser.add_argument('--proxy', help='Socks proxy address', metavar='ip:port')
|
||||||
self.parser.add_argument('--bind', help='Bind outgoing sockets to this address', metavar='ip')
|
self.parser.add_argument('--bind', help='Bind outgoing sockets to this address', metavar='ip')
|
||||||
self.parser.add_argument('--trackers', help='Bootstraping torrent trackers', default=trackers, metavar='protocol://address', nargs='*')
|
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('--trackers_file', help='Load torrent trackers dynamically from a file', metavar='path', nargs='*')
|
||||||
self.parser.add_argument('--trackers_proxy', help='Force use proxy to connect to trackers (disable, tor, ip:port)', default="disable")
|
self.parser.add_argument('--trackers_proxy', help='Force use proxy to connect to trackers (disable, tor, ip:port)', default="disable")
|
||||||
self.parser.add_argument('--use_libsecp256k1', help='Use Libsecp256k1 liblary for speedup', type='bool', choices=[True, False], default=True)
|
self.parser.add_argument('--use_libsecp256k1', help='Use Libsecp256k1 liblary for speedup', type='bool', choices=[True, False], default=True)
|
||||||
self.parser.add_argument('--use_openssl', help='Use OpenSSL liblary for speedup', type='bool', choices=[True, False], default=True)
|
self.parser.add_argument('--use_openssl', help='Use OpenSSL liblary for speedup', type='bool', choices=[True, False], default=True)
|
||||||
|
@ -296,20 +296,21 @@ class Config(object):
|
||||||
|
|
||||||
self.trackers = self.arguments.trackers[:]
|
self.trackers = self.arguments.trackers[:]
|
||||||
|
|
||||||
try:
|
for trackers_file in self.trackers_file:
|
||||||
if self.trackers_file.startswith("/"): # Absolute
|
try:
|
||||||
trackers_file_path = self.trackers_file
|
if trackers_file.startswith("/"): # Absolute
|
||||||
elif self.trackers_file.startswith("{data_dir}"): # Relative to data_dir
|
trackers_file_path = trackers_file
|
||||||
trackers_file_path = self.trackers_file.replace("{data_dir}", self.data_dir)
|
elif trackers_file.startswith("{data_dir}"): # Relative to data_dir
|
||||||
else: # Relative to zeronet.py
|
trackers_file_path = trackers_file.replace("{data_dir}", self.data_dir)
|
||||||
trackers_file_path = self.start_dir + "/" + self.trackers_file
|
else: # Relative to zeronet.py
|
||||||
|
trackers_file_path = self.start_dir + "/" + trackers_file
|
||||||
|
|
||||||
for line in open(trackers_file_path):
|
for line in open(trackers_file_path):
|
||||||
tracker = line.strip()
|
tracker = line.strip()
|
||||||
if "://" in tracker and tracker not in self.trackers:
|
if "://" in tracker and tracker not in self.trackers:
|
||||||
self.trackers.append(tracker)
|
self.trackers.append(tracker)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("Error loading trackers file: %s" % err)
|
print("Error loading trackers file: %s" % err)
|
||||||
|
|
||||||
# Find arguments specified for current action
|
# Find arguments specified for current action
|
||||||
def getActionArguments(self):
|
def getActionArguments(self):
|
||||||
|
|
Loading…
Reference in a new issue