diff options
author | Micah Lee <micah@micahflee.com> | 2019-10-13 14:35:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-13 14:35:40 -0400 |
commit | 896659c6963c14c4e047cff7f3d421977060ed23 (patch) | |
tree | 660468dd7478fb001ced211a4a33ae28a1b5f9a4 /onionshare/onionshare.py | |
parent | bbf6c02da645fcd4fc50db18dd341178ad4fa2e6 (diff) | |
parent | 7d24bf9ffcd1e21e087431c21bfc658803a61ab6 (diff) | |
download | onionshare-896659c6963c14c4e047cff7f3d421977060ed23.tar.gz onionshare-896659c6963c14c4e047cff7f3d421977060ed23.zip |
Merge pull request #1048 from micahflee/developv2.2
Version 2.2
Diffstat (limited to 'onionshare/onionshare.py')
-rw-r--r-- | onionshare/onionshare.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index e746bae1..41a4e5a8 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -22,17 +22,19 @@ import os, shutil from . import common, strings from .onion import TorTooOld, TorErrorProtocolError -from .common import AutoStopTimer +from .common import AutoStopTimer + class OnionShare(object): """ OnionShare is the main application class. Pass in options and run start_onion_service and it will do the magic. """ + def __init__(self, common, onion, local_only=False, autostop_timer=0): self.common = common - self.common.log('OnionShare', '__init__') + self.common.log("OnionShare", "__init__") # The Onion object self.onion = onion @@ -54,7 +56,7 @@ class OnionShare(object): self.autostop_timer_thread = None def set_stealth(self, stealth): - self.common.log('OnionShare', 'set_stealth', 'stealth={}'.format(stealth)) + self.common.log("OnionShare", "set_stealth", "stealth={}".format(stealth)) self.stealth = stealth self.onion.stealth = stealth @@ -66,13 +68,13 @@ class OnionShare(object): try: self.port = self.common.get_available_port(17600, 17650) except: - raise OSError(strings._('no_available_port')) + raise OSError(strings._("no_available_port")) def start_onion_service(self, await_publication=True, save_scheduled_key=False): """ Start the onionshare onion service. """ - self.common.log('OnionShare', 'start_onion_service') + self.common.log("OnionShare", "start_onion_service") if not self.port: self.choose_port() @@ -81,10 +83,12 @@ class OnionShare(object): self.autostop_timer_thread = AutoStopTimer(self.common, self.autostop_timer) if self.local_only: - self.onion_host = '127.0.0.1:{0:d}'.format(self.port) + self.onion_host = "127.0.0.1:{0:d}".format(self.port) return - self.onion_host = self.onion.start_onion_service(self.port, await_publication, save_scheduled_key) + self.onion_host = self.onion.start_onion_service( + self.port, await_publication, save_scheduled_key + ) if self.stealth: self.auth_string = self.onion.auth_string @@ -93,7 +97,7 @@ class OnionShare(object): """ Shut everything down and clean up temporary files, etc. """ - self.common.log('OnionShare', 'cleanup') + self.common.log("OnionShare", "cleanup") # Cleanup files try: |