mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Choose ports in range 17600-17650, so Tails can whitelist them (#220)
This commit is contained in:
parent
738c05a5f8
commit
3ed1f964cb
@ -51,11 +51,16 @@ class OnionShare(object):
|
||||
|
||||
def choose_port(self):
|
||||
"""
|
||||
Pick an un-used port to bind to.
|
||||
Pick an un-used port in the range 17600-17650 to bind to.
|
||||
"""
|
||||
# let the OS choose a port
|
||||
tmpsock = socket.socket()
|
||||
tmpsock.bind(("127.0.0.1", 0))
|
||||
for port in range(17600, 17650):
|
||||
try:
|
||||
tmpsock.bind(("127.0.0.1", port))
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
self.port = tmpsock.getsockname()[1]
|
||||
tmpsock.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user