summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-11-27 11:22:29 -0800
committerMicah Lee <micah@micahflee.com>2020-11-27 11:22:29 -0800
commit7927ef83b235e1219f7825e740db9ce216147aee (patch)
tree3fadf5ab0ca2fad04b4f3d2d6f881ec294b00780 /cli
parent752afcaa3a62785296d06baeb44ba00a4f30ad46 (diff)
downloadonionshare-7927ef83b235e1219f7825e740db9ce216147aee.tar.gz
onionshare-7927ef83b235e1219f7825e740db9ce216147aee.zip
Only wait for share mode rendezvous circuits to close, ignore the rest
Diffstat (limited to 'cli')
-rw-r--r--cli/onionshare_cli/__init__.py6
-rw-r--r--cli/onionshare_cli/onion.py15
-rw-r--r--cli/onionshare_cli/onionshare.py4
3 files changed, 17 insertions, 8 deletions
diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py
index dac42514..12808375 100644
--- a/cli/onionshare_cli/__init__.py
+++ b/cli/onionshare_cli/__init__.py
@@ -353,7 +353,7 @@ def main(cwd=None):
)
sys.exit()
- app.start_onion_service(mode_settings, False, True)
+ app.start_onion_service(mode, mode_settings, False, True)
url = build_url(mode_settings, app, web)
schedule = datetime.now() + timedelta(seconds=autostart_timer)
if mode == "receive":
@@ -389,9 +389,9 @@ def main(cwd=None):
print("Waiting for the scheduled time before starting...")
app.onion.cleanup(False)
time.sleep(autostart_timer)
- app.start_onion_service(mode_settings)
+ app.start_onion_service(mode, mode_settings)
else:
- app.start_onion_service(mode_settings)
+ app.start_onion_service(mode, mode_settings)
except KeyboardInterrupt:
print("")
sys.exit()
diff --git a/cli/onionshare_cli/onion.py b/cli/onionshare_cli/onion.py
index f10401da..b801997d 100644
--- a/cli/onionshare_cli/onion.py
+++ b/cli/onionshare_cli/onion.py
@@ -188,6 +188,9 @@ class Onion(object):
# Assigned later if we are using stealth mode
self.auth_string = None
+ # Keep track of onions where it's important to gracefully close to prevent truncated downloads
+ self.graceful_close_onions = []
+
def connect(
self,
custom_settings=None,
@@ -611,7 +614,7 @@ class Onion(object):
else:
return False
- def start_onion_service(self, mode_settings, port, await_publication):
+ def start_onion_service(self, mode, mode_settings, port, await_publication):
"""
Start a onion service on port 80, pointing to the given port, and
return the onion hostname.
@@ -691,6 +694,10 @@ class Onion(object):
onion_host = res.service_id + ".onion"
+ # Gracefully close share mode rendezvous circuits
+ if mode == "share":
+ self.graceful_close_onions.append(res.service_id)
+
# Save the service_id
mode_settings.set("general", "service_id", res.service_id)
@@ -754,9 +761,11 @@ class Onion(object):
try:
rendevouz_circuit_ids = []
for c in self.c.get_circuits():
- if c.purpose == "HS_SERVICE_REND":
+ if (
+ c.purpose == "HS_SERVICE_REND"
+ and c.rend_query in self.graceful_close_onions
+ ):
rendevouz_circuit_ids.append(c.id)
- # print(f"id={c.id} purpose={c.purpose} rend_query={c.rend_query} type={c.type}")
while True:
num_rend_circuits = 0
diff --git a/cli/onionshare_cli/onionshare.py b/cli/onionshare_cli/onionshare.py
index f74672ce..6fead913 100644
--- a/cli/onionshare_cli/onionshare.py
+++ b/cli/onionshare_cli/onionshare.py
@@ -63,7 +63,7 @@ class OnionShare(object):
except:
raise OSError("Cannot find an available OnionShare port")
- def start_onion_service(self, mode_settings, await_publication=True):
+ def start_onion_service(self, mode, mode_settings, await_publication=True):
"""
Start the onionshare onion service.
"""
@@ -80,7 +80,7 @@ class OnionShare(object):
return
self.onion_host = self.onion.start_onion_service(
- mode_settings, self.port, await_publication
+ mode, mode_settings, self.port, await_publication
)
if mode_settings.get("general", "client_auth"):