Skip to content

Commit

Permalink
Merge pull request #3983 from xoriole/devel_to_next_7.1.2
Browse files Browse the repository at this point in the history
Devel to next for 7.1.2
  • Loading branch information
qstokkink authored Oct 25, 2018
2 parents 979fc38 + 707023f commit 407afd3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Tribler/Core/Config/config.spec
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ directory = string(default='')
enabled = boolean(default=True)
port = integer(min=-1, max=65536, default=-1)
proxy_type = integer(min=0, max=5, default=0)
proxy_server = string_list(default=list('', ''))
proxy_auth = string_list(default=list('', ''))
proxy_server = string(default=':')
proxy_auth = string(default=':')
max_connections_download = integer(default=-1)
max_download_rate = integer(default=0)
max_upload_rate = integer(default=0)
Expand Down
13 changes: 9 additions & 4 deletions Tribler/Core/Config/tribler_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,18 @@ def set_libtorrent_proxy_settings(self, proxy_type, server=None, auth=None):
:param auth: (username, password) tuple or None
"""
self.config['libtorrent']['proxy_type'] = proxy_type
self.config['libtorrent']['proxy_server'] = server if proxy_type else None
self.config['libtorrent']['proxy_auth'] = auth if proxy_type in [3, 5] else None
self.config['libtorrent']['proxy_server'] = server if proxy_type else ':'
self.config['libtorrent']['proxy_auth'] = auth if proxy_type in [3, 5] else ':'

def get_libtorrent_proxy_settings(self):
proxy_server = str(self.config['libtorrent']['proxy_server'])
proxy_server = proxy_server.split(':') if proxy_server else ['', '']

proxy_auth = str(self.config['libtorrent']['proxy_auth'])
proxy_auth = proxy_auth.split(':') if proxy_auth else ['', '']

return (self.config['libtorrent']['proxy_type'],
self.config['libtorrent']['proxy_server'],
self.config['libtorrent']['proxy_auth'])
proxy_server, proxy_auth)

def set_anon_proxy_settings(self, proxy_type, server=None, auth=None):
"""
Expand Down
14 changes: 7 additions & 7 deletions Tribler/Test/Core/Config/test_tribler_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,18 @@ def test_libtorrent_proxy_settings(self):
"""
Setting and getting of libtorrent proxy settings.
"""
proxy_type, server, auth = 3, ("33.33.33.33", 22), 1
self.tribler_config.set_libtorrent_proxy_settings(proxy_type, server, auth)

proxy_type, server, auth = 3, ['33.33.33.33', '22'], ['user', 'pass']
self.tribler_config.set_libtorrent_proxy_settings(proxy_type, ':'.join(server), ':'.join(auth))
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[0], proxy_type)
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[1], server)
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[2], auth)

# if the proxy type doesn't support authentication, auth setting should be saved as None
proxy_type = 1
self.tribler_config.set_libtorrent_proxy_settings(proxy_type, server, auth)
self.tribler_config.set_libtorrent_proxy_settings(proxy_type, ':'.join(server), ':'.join(auth))
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[0], proxy_type)
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[1], server)
self.assertIsNone(self.tribler_config.get_libtorrent_proxy_settings()[2])
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings()[2], ['', ''])

def test_anon_proxy_settings(self):
proxy_type, server, auth = 3, ("33.33.33.33", [2222, 2223, 4443, 58848]), 1
Expand Down Expand Up @@ -195,8 +194,9 @@ def test_get_set_methods_libtorrent(self):
self.assertEqual(self.tribler_config.get_libtorrent_port(), True)
self.tribler_config.set_anon_listen_port(True)
self.assertEqual(self.tribler_config.get_anon_listen_port(), True)
self.tribler_config.set_libtorrent_proxy_settings(3, True, False)
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings(), (3, True, False))
proxy_server, proxy_auth = ["localhost", "9090"], ["user", "pass"]
self.tribler_config.set_libtorrent_proxy_settings(3, ":".join(proxy_server), ":".join(proxy_auth))
self.assertEqual(self.tribler_config.get_libtorrent_proxy_settings(), (3, proxy_server, proxy_auth))
self.tribler_config.set_anon_proxy_settings(0, None, None)
self.assertEqual(self.tribler_config.get_anon_proxy_settings(), (0, (None, None), None))
self.tribler_config.set_anon_proxy_settings(3, ("TEST", [5]), ("TUN", "TPW"))
Expand Down
6 changes: 3 additions & 3 deletions TriblerGUI/tribler_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ def on_new_version_dialog_done(self, version, action):
elif action == 2: # ok
import webbrowser
webbrowser.open("https://tribler.org")

self.new_version_dialog.close_dialog()
self.new_version_dialog = None
if self.new_version_dialog:
self.new_version_dialog.close_dialog()
self.new_version_dialog = None

def on_search_text_change(self, text):
self.search_suggestion_mgr = TriblerRequestManager()
Expand Down
25 changes: 15 additions & 10 deletions TriblerGUI/widgets/settingspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ def initialize_with_settings(self, settings):
# Connection settings
self.window().lt_proxy_type_combobox.setCurrentIndex(settings['libtorrent']['proxy_type'])
if settings['libtorrent']['proxy_server']:
self.window().lt_proxy_server_input.setText(settings['libtorrent']['proxy_server'][0])
self.window().lt_proxy_port_input.setText("%s" % settings['libtorrent']['proxy_server'][1])
proxy_server = settings['libtorrent']['proxy_server'].split(":")
self.window().lt_proxy_server_input.setText(proxy_server[0])
self.window().lt_proxy_port_input.setText(proxy_server[1])
if settings['libtorrent']['proxy_auth']:
self.window().lt_proxy_username_input.setText(settings['libtorrent']['proxy_auth'][0])
self.window().lt_proxy_password_input.setText(settings['libtorrent']['proxy_auth'][1])
proxy_auth = settings['libtorrent']['proxy_auth'].split(":")
self.window().lt_proxy_username_input.setText(proxy_auth[0])
self.window().lt_proxy_password_input.setText(proxy_auth[1])
self.window().lt_utp_checkbox.setChecked(settings['libtorrent']['utp'])

max_conn_download = settings['libtorrent']['max_connections_download']
Expand Down Expand Up @@ -337,21 +339,24 @@ def save_settings(self):

if self.window().lt_proxy_server_input.text() and len(self.window().lt_proxy_server_input.text()) > 0 and len(
self.window().lt_proxy_port_input.text()) > 0:
settings_data['libtorrent']['proxy_server'] = [self.window().lt_proxy_server_input.text(), None]
settings_data['libtorrent']['proxy_server'][0] = self.window().lt_proxy_server_input.text()
try:
settings_data['libtorrent']['proxy_server'][1] = int(self.window().lt_proxy_port_input.text())
settings_data['libtorrent']['proxy_server'] = "%s:%s" % (self.window().lt_proxy_server_input.text(),
int(self.window().lt_proxy_port_input.text()))
except ValueError:
ConfirmationDialog.show_error(self.window(), "Invalid proxy port number",
"You've entered an invalid format for the proxy port number. "
"Please enter a whole number.")
return
else:
settings_data['libtorrent']['proxy_server'] = ":"

if len(self.window().lt_proxy_username_input.text()) > 0 and \
len(self.window().lt_proxy_password_input.text()) > 0:
settings_data['libtorrent']['proxy_auth'] = [None, None]
settings_data['libtorrent']['proxy_auth'][0] = self.window().lt_proxy_username_input.text()
settings_data['libtorrent']['proxy_auth'][1] = self.window().lt_proxy_password_input.text()
settings_data['libtorrent']['proxy_auth'] = "%s:%s" % (self.window().lt_proxy_username_input.text(),
self.window().lt_proxy_password_input.text())
else:
settings_data['libtorrent']['proxy_auth'] = ":"

settings_data['libtorrent']['utp'] = self.window().lt_utp_checkbox.isChecked()

try:
Expand Down
22 changes: 14 additions & 8 deletions run_tribler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging.config

import signal

from Tribler.Core.exceptions import TriblerException
from check_os import check_environment, check_free_space, error_and_exit, setup_gui_logging, \
should_kill_other_tribler_instances, enable_fault_handler, set_process_priority

Expand Down Expand Up @@ -83,19 +85,19 @@ def start_tribler():
api_port = os.environ['CORE_API_PORT']
start_tribler_core(base_path, api_port)
else:
enable_fault_handler()
try:
enable_fault_handler()

# Exit if we cant read/write files, etc.
check_environment()
# Exit if we cant read/write files, etc.
check_environment()

should_kill_other_tribler_instances()
should_kill_other_tribler_instances()

check_free_space()
check_free_space()

# Set up logging
setup_gui_logging()
# Set up logging
setup_gui_logging()

try:
from TriblerGUI.tribler_app import TriblerApplication
from TriblerGUI.tribler_window import TriblerWindow

Expand All @@ -118,6 +120,10 @@ def start_tribler():
logging.exception(ie)
error_and_exit("Import Error", "Import error: {0}".format(ie))

except TriblerException as te:
logging.exception(te)
error_and_exit("Tribler Exception", "{0}".format(te))

except SystemExit as se:
logging.info("Shutting down Tribler")
# Flush all the logs to make sure it is written to file before it exits
Expand Down

0 comments on commit 407afd3

Please sign in to comment.