diff --git a/src/config.py b/src/config.py index 4d9f203a..e55ec95b 100644 --- a/src/config.py +++ b/src/config.py @@ -8,7 +8,7 @@ log = logging.getLogger("config") MAINFILE = "twblue.conf" MAINSPEC = "app-configuration.defaults" - +proxyTypes=[u"http", u"https", u"socks4", u"socks5"] app = None keymap=None changed_keymap = False diff --git a/src/controller/settings.py b/src/controller/settings.py index 68825a7d..af49fb1d 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -67,9 +67,12 @@ class globalSettingsController(object): self.dialog.set_value("general", "disable_sapi5", config.app["app-settings"]["voice_enabled"]) self.dialog.set_value("general", "hide_gui", config.app["app-settings"]["hide_gui"]) self.dialog.set_value("general", "check_for_updates", config.app["app-settings"]["check_for_updates"]) - proxyTypes=[_(u"Direct connection"), u"http", u"https", u"socks4", u"socks5"] - self.dialog.create_proxy(proxyTypes) - self.dialog.proxy.type.SetSelection(proxyTypes.index(config.app["proxy"]["type"])) + proxyTypes=config.proxyTypes + self.dialog.create_proxy([_(u"Direct connection")]+proxyTypes) + if config.app["proxy"]["type"] not in proxyTypes: + self.dialog.proxy.type.SetSelection(0) + else: + self.dialog.proxy.type.SetSelection(proxyTypes.index(config.app["proxy"]["type"])+1) self.dialog.set_value("proxy", "server", config.app["proxy"]["server"]) self.dialog.set_value("proxy", "port", config.app["proxy"]["port"]) self.dialog.set_value("proxy", "user", config.app["proxy"]["user"]) diff --git a/src/fixes/fix_requests.py b/src/fixes/fix_requests.py index e6589fbe..b9d999bb 100644 --- a/src/fixes/fix_requests.py +++ b/src/fixes/fix_requests.py @@ -15,17 +15,9 @@ def fix(): def patched_session_init(self): orig_session_init(self) - if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "": - self.proxies={"http":"http://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "https://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "http": "socks5://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "socks5://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "http": "socks4://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "socks4://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"])} + if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "" and config.app["proxy"]["type"] in config.proxyTypes: + self.proxies={"http":"{0}://{1}:{2}/".format(config.app["proxy"]["type"], config.app["proxy"]["server"], config.app["proxy"]["port"]), + "https": "{0}://{1}:{2}/".format(config.app["proxy"]["type"], config.app["proxy"]["server"], config.app["proxy"]["port"])} if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "": - self.proxies={"http": "http://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "https://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "http": "socks5://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "socks5://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "http": "socks4://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), - "https": "socks4://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"])} + self.proxies={"http": "{0}://{1}:{2}@{3}:{4}/".format(config.app["proxy"]["type"], config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]), + "https": "{0}://{1}:{2}@{3}:{4}/".format(config.app["proxy"]["type"], config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"])}