From ce93125c990775fde104aea0ed716a8b7fb64f69 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 21 May 2014 14:56:09 -0400 Subject: [PATCH] make script work even if ONIONSHARE_PLATFORM isn't set --- onionshare.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/onionshare.py b/onionshare.py index d6a56f50..75a66957 100755 --- a/onionshare.py +++ b/onionshare.py @@ -48,13 +48,19 @@ def download(): basename = os.path.basename(filename) return send_from_directory(dirname, basename, as_attachment=True) +def get_platform(): + if 'ONIONSHARE_PLATFORM' in os.environ: + return os.environ['ONIONSHARE_PLATFORM'] + else: + return 'unknown' + def tails_open_port(port): - if os.environ['ONIONSHARE_PLATFORM'] == 'Tails': + if get_platform() == 'Tails': print 'Punching a hole in the firewall' subprocess.call(['/sbin/iptables', '-I', 'OUTPUT', '-o', 'lo', '-p', 'tcp', '--dport', str(port), '-j', 'ACCEPT']) def tails_close_port(port): - if os.environ['ONIONSHARE_PLATFORM'] == 'Tails': + if get_platform() == 'Tails': print 'Closing hole in firewall' subprocess.call(['/sbin/iptables', '-I', 'OUTPUT', '-o', 'lo', '-p', 'tcp', '--dport', str(port), '-j', 'REJECT'])