make socks4 port configurable. (Closes: #797339)

Thanks to Michael Gold <michael@bitplane.org> for the original patch
This commit is contained in:
Holger Levsen 2016-03-01 13:08:39 +01:00
parent 3f536f5341
commit a34eacfb06
3 changed files with 19 additions and 2 deletions

View File

@ -194,6 +194,7 @@ class Common:
'installed': False,
'download_over_tor': False,
'modem_sound': False,
'tor_socks_address': 'tcp:127.0.0.1:9050',
'mirror': self.default_mirror
}

View File

@ -386,10 +386,10 @@ class Launcher:
self.refresh_gtk()
if self.common.settings['download_over_tor']:
from twisted.internet.endpoints import TCP4ClientEndpoint
from twisted.internet.endpoints import clientFromString
from txsocksx.http import SOCKS5Agent
torEndpoint = TCP4ClientEndpoint(reactor, '127.0.0.1', 9050)
torEndpoint = clientFromString(reactor, self.common.settings['tor_socks_address'])
# default mirror gets certificate pinning, only for requests that use the mirror
agent = SOCKS5Agent(reactor, proxyEndpoint=torEndpoint)

View File

@ -101,6 +101,21 @@ class Settings:
self.modem_checkbox.set_tooltip_text(_("This option requires python-pygame to be installed"))
self.modem_checkbox.show()
# Tor SOCKS address
self.tor_addr_box = gtk.HBox(False, 10)
self.settings_box.pack_start(self.tor_addr_box, True, True, 0)
self.tor_addr_box.show()
self.tor_addr_label = gtk.Label(_('Tor server'))
self.tor_addr_label.set_line_wrap(True)
self.tor_addr_box.pack_start(self.tor_addr_label, True, True, 0)
self.tor_addr_label.show()
self.tor_addr = gtk.Entry()
self.tor_addr.set_text(self.common.settings['tor_socks_address'])
self.tor_addr_box.pack_start(self.tor_addr, True, True, 0)
self.tor_addr.show()
# status
if(self.common.settings['installed']):
self.status_label = gtk.Label(_('Status: Installed'))
@ -212,6 +227,7 @@ class Settings:
# checkbox options
self.common.settings['download_over_tor'] = self.tor_download_checkbox.get_active()
self.common.settings['modem_sound'] = self.modem_checkbox.get_active()
self.common.settings['tor_socks_address'] = self.tor_addr.get_text()
# figure out the selected mirror
self.common.settings['mirror'] = self.common.mirrors[self.mirrors.get_active()]