mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-15 17:27:35 -05:00
try connecting to Tor SOCKS5 server on ports 9050 and 9150, instead of just 9150 (#136)
This commit is contained in:
parent
a314ca891d
commit
bfcd5190bd
@ -91,15 +91,16 @@ class OnionShare(object):
|
|||||||
self.cleanup_filenames.append(hidserv_dir)
|
self.cleanup_filenames.append(hidserv_dir)
|
||||||
|
|
||||||
# connect to the tor controlport
|
# connect to the tor controlport
|
||||||
controlports = [9051, 9151]
|
|
||||||
controller = False
|
controller = False
|
||||||
for controlport in controlports:
|
tor_control_ports = [9051, 9151]
|
||||||
|
for tor_control_port in tor_control_ports:
|
||||||
try:
|
try:
|
||||||
controller = Controller.from_port(port=controlport)
|
controller = Controller.from_port(port=tor_control_port)
|
||||||
|
break
|
||||||
except SocketError:
|
except SocketError:
|
||||||
pass
|
pass
|
||||||
if not controller:
|
if not controller:
|
||||||
raise NoTor(strings._("cant_connect_ctrlport").format(controlports))
|
raise NoTor(strings._("cant_connect_ctrlport").format(tor_control_ports))
|
||||||
controller.authenticate()
|
controller.authenticate()
|
||||||
|
|
||||||
# set up hidden service
|
# set up hidden service
|
||||||
@ -129,11 +130,20 @@ class OnionShare(object):
|
|||||||
# so no need to set the socks5 proxy
|
# so no need to set the socks5 proxy
|
||||||
urllib2.urlopen('http://{0}'.format(self.onion_host))
|
urllib2.urlopen('http://{0}'.format(self.onion_host))
|
||||||
else:
|
else:
|
||||||
s = socks.socksocket()
|
tor_exists = False
|
||||||
s.setproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9150)
|
tor_socks_ports = [9050, 9150]
|
||||||
s.connect((self.onion_host, 80))
|
for tor_socks_port in tor_socks_ports:
|
||||||
#s.sendall('GET / HTTP/1.1\r\n\r\n')
|
try:
|
||||||
s.close()
|
s = socks.socksocket()
|
||||||
|
s.setproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', tor_socks_port)
|
||||||
|
s.connect((self.onion_host, 80))
|
||||||
|
s.close()
|
||||||
|
tor_exists = True
|
||||||
|
break
|
||||||
|
except socks.ProxyConnectionError:
|
||||||
|
pass
|
||||||
|
if not tor_exists:
|
||||||
|
raise NoTor(strings._("cant_connect_socksport").format(tor_socks_ports))
|
||||||
ready = True
|
ready = True
|
||||||
|
|
||||||
sys.stdout.write('{0}\n'.format(strings._('wait_for_hs_yup')))
|
sys.stdout.write('{0}\n'.format(strings._('wait_for_hs_yup')))
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"calculating_sha1": "Calculating SHA1 checksum.",
|
"calculating_sha1": "Calculating SHA1 checksum.",
|
||||||
"connecting_ctrlport": "Connecting to Tor control port to set up hidden service on port {0}.",
|
"connecting_ctrlport": "Connecting to Tor control port to set up hidden service on port {0}.",
|
||||||
"cant_connect_ctrlport": "Cannot connect to Tor control port on port {0}. Is Tor running?",
|
"cant_connect_ctrlport": "Cannot connect to Tor control port on port {0}. Is Tor running?",
|
||||||
|
"cant_connect_socksport": "Cannot connect to Tor SOCKS5 server on port {0}. Is Tor running?",
|
||||||
"preparing_files": "Preparing files to share.",
|
"preparing_files": "Preparing files to share.",
|
||||||
"wait_for_hs": "Waiting for HS to be ready:",
|
"wait_for_hs": "Waiting for HS to be ready:",
|
||||||
"wait_for_hs_trying": "Trying...",
|
"wait_for_hs_trying": "Trying...",
|
||||||
|
Loading…
Reference in New Issue
Block a user