[Pkg-privacy-commits] [onionshare] 37/66: Choose ports in range 17600-17650, so Tails can whitelist them (#220)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Wed Apr 13 22:17:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit 3ed1f964cb5b66fa9af5df229c37323ef1e3aa46
Author: Micah Lee <micah at micahflee.com>
Date: Sat Feb 27 18:03:42 2016 +0100
Choose ports in range 17600-17650, so Tails can whitelist them (#220)
---
onionshare/onionshare.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index fa882fd..34e64b0 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -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()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git
More information about the Pkg-privacy-commits
mailing list