Commit cb8cbef3 authored by prx's avatar prx

support de proxy. À tester

parent b8867422
......@@ -570,7 +570,10 @@ class DontPanic:
@self.app.route("/stream/<name>/<magnet:path>/<isserie>")
def stream(name, magnet, isserie):
# Start download
newses = TorrentSession()
if self.proxy != "none":
newses = TorrentSession(self.proxy_type, self.proxy_hostname, self.proxy_username, self.proxy_password)
else:
newses = TorrentSession()
newses.download(magnet, self.tmp, self.uplimit, self.downlimit)
index = 1
......
......@@ -7,7 +7,7 @@ Bugs:
À faire:
--------
- Associer les liens magnets à dontpanic sous windows
- Configuration d'un VPN : voir là http://www.libtorrent.org/reference-Settings.html
- Configuration d'un proxy : voir là http://www.libtorrent.org/reference-Settings.html : ok, à tester!!!
Suggestion:
-----------
......
......@@ -26,7 +26,7 @@ class TorrentSession:
# Special Methods #
###############################################
def __init__(self):
def __init__(self, proxy_type=None, proxy_hostname=None, proxy_username=None, proxy_password=None):
self._magnet = None
self._handle = None
self._temp_dir = str()
......@@ -42,6 +42,39 @@ class TorrentSession:
pe.prefer_rc4 = True
self._session.set_pe_settings(pe)
ss = self._session.get_settings()
ss['anonymous_mode'] = True
if proxy_type != None:
ps = lt.proxy_settings()
if proxy_type == "none":
ps.type = lt.proxy_type.none
elif proxy_type == "socks4":
ps.type = lt.proxy_type.socks4
elif proxy_type == "socks5":
ps.type = lt.proxy_type.socks5
elif proxy_type == "socks5_pw":
ps.type = lt.proxy_type.socks5_pw
elif proxy_type == "http":
ps.type = lt.proxy_type.http
elif proxy_type == "http_pw":
ps.type = lt.proxy_type.http_pw
elif proxy_type == "i2p_proxy":
ps.type = lt.proxy_type.i2p_proxy
if proxy_type != "none":
ss['force_proxy'] = True
if proxy_hostname != None:
ps.hostname = proxy_hostname
if proxy_username != None:
ps.username = proxy_username
if proxy_password != None:
ps.password = proxy_password
self._session.set_settings(ss)
self._session.set_proxy(ps)
self._session.listen_on(6881, 6891)
self._session.start_dht()
for addr in self.ROUTER_ADDR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment