mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-26 17:31:21 -05: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):
|
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
|
# let the OS choose a port
|
||||||
tmpsock = socket.socket()
|
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]
|
self.port = tmpsock.getsockname()[1]
|
||||||
tmpsock.close()
|
tmpsock.close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user