summaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2019-03-11 15:55:17 +1100
committerMiguel Jacq <mig@mig5.net>2019-03-11 15:55:17 +1100
commit365798b12f1e887d75b20266f0b636c756969427 (patch)
tree041c9856b4baecdc3e46f3e3caacbb6536052ef4 /onionshare
parent040e7e4ca9c383248457496a9071dba16134e138 (diff)
downloadonionshare-365798b12f1e887d75b20266f0b636c756969427.tar.gz
onionshare-365798b12f1e887d75b20266f0b636c756969427.zip
Various Startup Timer fixes for strings, bundled mode, stealth mode, startup/shutdown time clashes
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/__init__.py67
-rw-r--r--onionshare/onion.py26
2 files changed, 66 insertions, 27 deletions
diff --git a/onionshare/__init__.py b/onionshare/__init__.py
index 601631a2..48ab8c4a 100644
--- a/onionshare/__init__.py
+++ b/onionshare/__init__.py
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import os, sys, time, argparse, threading
+from datetime import datetime
+from datetime import timedelta
from . import strings
from .common import Common
@@ -137,9 +139,27 @@ def main(cwd=None):
url = 'http://{0:s}'.format(app.onion_host)
else:
url = 'http://{0:s}/{1:s}'.format(app.onion_host, web.slug)
- print(strings._("scheduled_onion_service").format(url))
- app.onion.cleanup()
- print(strings._("waiting_for_startup_timer"))
+ schedule = datetime.now() + timedelta(seconds=startup_timer)
+ if mode == 'receive':
+ print(strings._('receive_mode_data_dir').format(common.settings.get('data_dir')))
+ print('')
+ print(strings._('receive_mode_warning'))
+ print('')
+ if stealth:
+ print(strings._("give_this_scheduled_url_receive_stealth").format(schedule.strftime("%b %d, %I:%M:%S%p")))
+ print(app.auth_string)
+ else:
+ print(strings._("give_this_scheduled_url_receive").format(schedule.strftime("%b %d, %I:%M:%S%p")))
+ else:
+ if stealth:
+ print(strings._("give_this_scheduled_url_share_stealth").format(schedule.strftime("%b %d, %I:%M:%S%p")))
+ print(app.auth_string)
+ else:
+ print(strings._("give_this_scheduled_url_share").format(schedule.strftime("%b %d, %I:%M:%S%p")))
+ print(url)
+ print('')
+ print(strings._("waiting_for_scheduled_time"))
+ app.onion.cleanup(False)
time.sleep(startup_timer)
app.start_onion_service()
else:
@@ -194,27 +214,30 @@ def main(cwd=None):
url = 'http://{0:s}/{1:s}'.format(app.onion_host, web.slug)
print('')
- if mode == 'receive':
- print(strings._('receive_mode_data_dir').format(common.settings.get('data_dir')))
- print('')
- print(strings._('receive_mode_warning'))
- print('')
-
- if stealth:
- print(strings._("give_this_url_receive_stealth"))
- print(url)
- print(app.auth_string)
- else:
- print(strings._("give_this_url_receive"))
- print(url)
+ if startup_timer > 0:
+ print(strings._('server_started'))
else:
- if stealth:
- print(strings._("give_this_url_stealth"))
- print(url)
- print(app.auth_string)
+ if mode == 'receive':
+ print(strings._('receive_mode_data_dir').format(common.settings.get('data_dir')))
+ print('')
+ print(strings._('receive_mode_warning'))
+ print('')
+
+ if stealth:
+ print(strings._("give_this_url_receive_stealth"))
+ print(url)
+ print(app.auth_string)
+ else:
+ print(strings._("give_this_url_receive"))
+ print(url)
else:
- print(strings._("give_this_url"))
- print(url)
+ if stealth:
+ print(strings._("give_this_url_stealth"))
+ print(url)
+ print(app.auth_string)
+ else:
+ print(strings._("give_this_url"))
+ print(url)
print('')
print(strings._("ctrlc_to_stop"))
diff --git a/onionshare/onion.py b/onionshare/onion.py
index 17621b01..8d4e50a0 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -134,6 +134,7 @@ class Onion(object):
self.stealth = False
self.service_id = None
self.scheduled_key = None
+ self.scheduled_auth_cookie = None
# Is bundled tor supported?
if (self.common.platform == 'Windows' or self.common.platform == 'Darwin') and getattr(sys, 'onionshare_dev_mode', False):
@@ -430,21 +431,25 @@ class Onion(object):
return the onion hostname.
"""
self.common.log('Onion', 'start_onion_service')
-
self.auth_string = None
+
if not self.supports_ephemeral:
raise TorTooOld(strings._('error_ephemeral_not_supported'))
if self.stealth and not self.supports_stealth:
raise TorTooOld(strings._('error_stealth_not_supported'))
- print(strings._("config_onion_service").format(int(port)))
+ if not save_scheduled_key:
+ print(strings._("config_onion_service").format(int(port)))
if self.stealth:
if self.settings.get('hidservauth_string'):
hidservauth_string = self.settings.get('hidservauth_string').split()[2]
basic_auth = {'onionshare':hidservauth_string}
else:
- basic_auth = {'onionshare':None}
+ if self.scheduled_auth_cookie:
+ basic_auth = {'onionshare':self.scheduled_auth_cookie}
+ else:
+ basic_auth = {'onionshare':None}
else:
basic_auth = None
@@ -521,8 +526,19 @@ class Onion(object):
self.auth_string = 'HidServAuth {} {}'.format(onion_host, auth_cookie)
self.settings.set('hidservauth_string', self.auth_string)
else:
- auth_cookie = list(res.client_auth.values())[0]
- self.auth_string = 'HidServAuth {} {}'.format(onion_host, auth_cookie)
+ if not self.scheduled_auth_cookie:
+ auth_cookie = list(res.client_auth.values())[0]
+ self.auth_string = 'HidServAuth {} {}'.format(onion_host, auth_cookie)
+ if save_scheduled_key:
+ # Register the HidServAuth for the scheduled share
+ self.scheduled_auth_cookie = auth_cookie
+ else:
+ self.scheduled_auth_cookie = None
+ else:
+ self.auth_string = 'HidServAuth {} {}'.format(onion_host, self.scheduled_auth_cookie)
+ if not save_scheduled_key:
+ # We've used the scheduled share's HidServAuth. Reset it to None for future shares
+ self.scheduled_auth_cookie = None
if onion_host is not None:
self.settings.save()