Параметры поддержки раздачи и приёма соединений пиров
parent
bf655e3f96
commit
6e64e0a1f4
|
@ -45,108 +45,34 @@ class Engine:
|
|||
else:
|
||||
xbmc.log("[gorrent2http] %s" % message)
|
||||
|
||||
def __init__(self, uri=None, platform=None, download_path=".",
|
||||
bind_host='127.0.0.1', bind_port=5001, connections_limit=200, download_kbps=-1, upload_kbps=-1,
|
||||
enable_dht=True, enable_lsd=True, enable_natpmp=True, enable_upnp=True, enable_scrape=False,
|
||||
log_stats=False, encryption=Encryption.ENABLED, keep_complete=False, keep_incomplete=False,
|
||||
keep_files=False, log_files_progress=False, log_overall_progress=False, log_pieces_progress=False,
|
||||
listen_port=6881, use_random_port=False, max_idle_timeout=None, no_sparse=False, resume_file='',
|
||||
user_agent=None, startup_timeout=5, state_file='', enable_utp=True, enable_tcp=True,
|
||||
debug_alerts=False, logger=None, torrent_connect_boost=50, connection_speed=50,
|
||||
peer_connect_timeout=15, request_timeout=20, min_reconnect_time=60, max_failcount=3,
|
||||
dht_routers=None, trackers=None, proxy=None):
|
||||
"""
|
||||
Creates engine instance. It doesn't do anything except initializing object members. For starting engine use
|
||||
start() method.
|
||||
def __init__(self, uri=None, download_path=".",
|
||||
bind_host='127.0.0.1', bind_port=5001, connections_limit=200,
|
||||
keep_files=False,
|
||||
listen_port=6881,
|
||||
debug_alerts=False,
|
||||
proxy=None,
|
||||
seed=True,
|
||||
accept_peer_conn=True,
|
||||
startup_timeout=5,
|
||||
logger=None,
|
||||
):
|
||||
|
||||
:param uri: Torrent URI (magnet://, file:// or http://)
|
||||
:param platform: Object with two methods implemented: arch() and system()
|
||||
:param download_path: Torrent download path
|
||||
:param bind_host: Bind host of torrent2http
|
||||
:param bind_port: Bind port of torrent2http
|
||||
:param connections_limit: Set a global limit on the number of connections opened
|
||||
:param download_kbps: Max download rate (kB/s)
|
||||
:param upload_kbps: Max upload rate (kB/s)
|
||||
:param enable_dht: Enable DHT (Distributed Hash Table)
|
||||
:param enable_lsd: Enable LSD (Local Service Discovery)
|
||||
:param enable_natpmp: Enable NATPMP (NAT port-mapping)
|
||||
:param enable_upnp: Enable UPnP (UPnP port-mapping)
|
||||
:param enable_scrape: Enable sending scrape request to tracker (updates total peers/seeds count)
|
||||
:param log_stats: Log all stats (incl. log_overall_progress, log_files_progress, log_pieces_progress)
|
||||
:param encryption: Encryption: 0=forced 1=enabled (default) 2=disabled
|
||||
:param keep_complete: Keep complete files after exiting
|
||||
:param keep_incomplete: Keep incomplete files after exiting
|
||||
:param keep_files: Keep all files after exiting (incl. keep_complete and keep_incomplete)
|
||||
:param log_files_progress: Log files progress
|
||||
:param log_overall_progress: Log overall progress
|
||||
:param log_pieces_progress: Log pieces progress
|
||||
:param listen_port: Use specified port for incoming connections
|
||||
:param use_random_port: Use random listen port (49152-65535)
|
||||
:param max_idle_timeout: Automatically shutdown torrent2http if no connection are active after a timeout
|
||||
:param no_sparse: Do not use sparse file allocation
|
||||
:param resume_file: Use fast resume file
|
||||
:param user_agent: Set an user agent
|
||||
:param startup_timeout: torrent2http startup timeout
|
||||
:param state_file: Use file for saving/restoring session state
|
||||
:param enable_utp: Enable uTP protocol
|
||||
:param enable_tcp: Enable TCP protocol
|
||||
:param debug_alerts: Show debug alert notifications
|
||||
:param logger: Instance of logging.Logger
|
||||
:param torrent_connect_boost: The number of peers to try to connect to immediately when the first tracker
|
||||
response is received for a torrent
|
||||
:param connection_speed: The number of peer connection attempts that are made per second
|
||||
:param peer_connect_timeout: The number of seconds to wait after a connection attempt is initiated to a peer
|
||||
:param request_timeout: The number of seconds until the current front piece request will time out
|
||||
:param min_reconnect_time: The time to wait between peer connection attempts. If the peer fails, the time is
|
||||
multiplied by fail counter
|
||||
:param max_failcount: The maximum times we try to connect to a peer before stop connecting again
|
||||
:param dht_routers: List of additional DHT routers (host:port pairs)
|
||||
:param trackers: List of additional tracker URLs
|
||||
"""
|
||||
self.dht_routers = dht_routers or []
|
||||
self.trackers = trackers or []
|
||||
self.max_failcount = max_failcount
|
||||
self.min_reconnect_time = min_reconnect_time
|
||||
self.request_timeout = request_timeout
|
||||
self.peer_connect_timeout = peer_connect_timeout
|
||||
self.connection_speed = connection_speed
|
||||
self.torrent_connect_boost = torrent_connect_boost
|
||||
self.platform = platform
|
||||
self.bind_host = bind_host
|
||||
self.bind_port = bind_port
|
||||
self.download_path = download_path
|
||||
self.connections_limit = connections_limit
|
||||
self.download_kbps = download_kbps
|
||||
self.upload_kbps = upload_kbps
|
||||
self.enable_dht = enable_dht
|
||||
self.enable_lsd = enable_lsd
|
||||
self.enable_natpmp = enable_natpmp
|
||||
self.enable_upnp = enable_upnp
|
||||
self.enable_scrape = enable_scrape
|
||||
self.log_stats = log_stats
|
||||
self.encryption = encryption
|
||||
self.keep_complete = keep_complete
|
||||
self.keep_incomplete = keep_incomplete
|
||||
self.keep_files = keep_files
|
||||
self.log_files_progress = log_files_progress
|
||||
self.log_overall_progress = log_overall_progress
|
||||
self.log_pieces_progress = log_pieces_progress
|
||||
self.listen_port = listen_port
|
||||
self.use_random_port = use_random_port
|
||||
self.max_idle_timeout = max_idle_timeout
|
||||
self.no_sparse = no_sparse
|
||||
self.resume_file = resume_file
|
||||
self.user_agent = user_agent
|
||||
self.startup_timeout = startup_timeout
|
||||
self.state_file = state_file
|
||||
self.wait_on_close_timeout = None
|
||||
self.enable_utp = enable_utp
|
||||
self.enable_tcp = enable_tcp
|
||||
self.debug_alerts = debug_alerts
|
||||
self.logger = logger
|
||||
self.uri = uri
|
||||
self.started = False
|
||||
self.proxy = proxy
|
||||
self.seed = seed
|
||||
self.accept_peer_conn = accept_peer_conn
|
||||
self.startup_timeout = startup_timeout
|
||||
self.logger = logger
|
||||
|
||||
self.message_logger = None
|
||||
self.run_message_logger = True
|
||||
|
@ -198,8 +124,11 @@ class Engine:
|
|||
settings.Debug = self.debug_alerts
|
||||
settings.KeepFiles = self.keep_files
|
||||
settings.Proxy = len(self.proxy) > 0 and f'socks5://{self.proxy["host"]}:{self.proxy["port"]}' or ''
|
||||
settings.Seed = self.seed
|
||||
settings.AcceptPeerConnections = self.accept_peer_conn
|
||||
|
||||
self.engine = gt.NewEngine(settings)
|
||||
|
||||
def msg_logger():
|
||||
while self.run_message_logger:
|
||||
msg = self.engine.GetMsg()
|
||||
|
|
Loading…
Reference in New Issue