summaryrefslogtreecommitdiff
path: root/cli/onionshare_cli/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'cli/onionshare_cli/__init__.py')
-rw-r--r--cli/onionshare_cli/__init__.py101
1 files changed, 28 insertions, 73 deletions
diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py
index c046e472..4bc00929 100644
--- a/cli/onionshare_cli/__init__.py
+++ b/cli/onionshare_cli/__init__.py
@@ -38,14 +38,6 @@ from .onionshare import OnionShare
from .mode_settings import ModeSettings
-def build_url(mode_settings, app, web):
- # Build the URL
- if mode_settings.get("general", "public"):
- return f"http://{app.onion_host}"
- else:
- return f"http://onionshare:{web.password}@{app.onion_host}"
-
-
def main(cwd=None):
"""
The main() function implements all of the logic that the command-line version of
@@ -113,7 +105,7 @@ def main(cwd=None):
action="store_true",
dest="public",
default=False,
- help="Don't use a password",
+ help="Don't use a private key",
)
parser.add_argument(
"--auto-start-timer",
@@ -129,20 +121,6 @@ def main(cwd=None):
default=0,
help="Stop onion service at schedule time (N seconds from now)",
)
- parser.add_argument(
- "--legacy",
- action="store_true",
- dest="legacy",
- default=False,
- help="Use legacy address (v2 onion service, not recommended)",
- )
- parser.add_argument(
- "--client-auth",
- action="store_true",
- dest="client_auth",
- default=False,
- help="Use client authorization (requires --legacy)",
- )
# Share args
parser.add_argument(
"--no-autostop-sharing",
@@ -215,8 +193,6 @@ def main(cwd=None):
public = bool(args.public)
autostart_timer = int(args.autostart_timer)
autostop_timer = int(args.autostop_timer)
- legacy = bool(args.legacy)
- client_auth = bool(args.client_auth)
autostop_sharing = not bool(args.no_autostop_sharing)
data_dir = args.data_dir
webhook_url = args.webhook_url
@@ -225,25 +201,9 @@ def main(cwd=None):
disable_csp = bool(args.disable_csp)
verbose = bool(args.verbose)
- if receive:
- mode = "receive"
- elif website:
- mode = "website"
- elif chat:
- mode = "chat"
- else:
- mode = "share"
-
# Verbose mode?
common.verbose = verbose
- # client_auth can only be set if legacy is also set
- if client_auth and not legacy:
- print(
- "Client authentication (--client-auth) is only supported with with legacy onion services (--legacy)"
- )
- sys.exit()
-
# Re-load settings, if a custom config was passed in
if config_filename:
common.load_settings(config_filename)
@@ -254,18 +214,26 @@ def main(cwd=None):
if persistent_filename:
mode_settings = ModeSettings(common, persistent_filename)
mode_settings.set("persistent", "enabled", True)
- mode_settings.set("persistent", "mode", mode)
else:
mode_settings = ModeSettings(common)
+ if receive:
+ mode = "receive"
+ elif website:
+ mode = "website"
+ elif chat:
+ mode = "chat"
+ else:
+ mode = "share"
+
if mode_settings.just_created:
# This means the mode settings were just created, not loaded from disk
mode_settings.set("general", "title", title)
mode_settings.set("general", "public", public)
mode_settings.set("general", "autostart_timer", autostart_timer)
mode_settings.set("general", "autostop_timer", autostop_timer)
- mode_settings.set("general", "legacy", legacy)
- mode_settings.set("general", "client_auth", client_auth)
+ if persistent_filename:
+ mode_settings.set("persistent", "mode", mode)
if mode == "share":
mode_settings.set("share", "autostop_sharing", autostop_sharing)
if mode == "receive":
@@ -352,11 +320,6 @@ def main(cwd=None):
try:
common.settings.load()
- if mode_settings.get("general", "public"):
- web.password = None
- else:
- web.generate_password(mode_settings.get("onion", "password"))
-
# Receive mode needs to know the tor proxy details for webhooks
if mode == "receive":
if local_only:
@@ -381,7 +344,7 @@ def main(cwd=None):
sys.exit()
app.start_onion_service(mode, mode_settings, False)
- url = build_url(mode_settings, app, web)
+ url = f"http://{app.onion_host}"
schedule = datetime.now() + timedelta(seconds=autostart_timer)
if mode == "receive":
print(
@@ -394,21 +357,21 @@ def main(cwd=None):
"what you are doing."
)
print("")
- if mode_settings.get("general", "client_auth"):
+ if not mode_settings.get("general", "public"):
print(
- f"Give this address and HidServAuth lineto your sender, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
+ f"Give this address and private key to your sender, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
)
- print(app.auth_string)
+ print(f"Private key: {app.auth_string}")
else:
print(
f"Give this address to your sender, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
)
else:
- if mode_settings.get("general", "client_auth"):
+ if not mode_settings.get("general", "public"):
print(
- f"Give this address and HidServAuth line to your recipient, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
+ f"Give this address and private key to your recipient, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
)
- print(app.auth_string)
+ print(f"Private key: {app.auth_string}")
else:
print(
f"Give this address to your recipient, and tell them it won't be accessible until: {schedule.strftime('%I:%M:%S%p, %b %d, %y')}"
@@ -426,7 +389,6 @@ def main(cwd=None):
sys.exit()
except (TorTooOldEphemeral, TorTooOldStealth, TorErrorProtocolError) as e:
print("")
- print(e.args[0])
sys.exit()
if mode == "website":
@@ -458,21 +420,14 @@ def main(cwd=None):
t.start()
try: # Trap Ctrl-C
- # Wait for web.generate_password() to finish running
time.sleep(0.2)
# start auto-stop timer thread
if app.autostop_timer > 0:
app.autostop_timer_thread.start()
- # Save the web password if we are using a persistent private key
- if mode_settings.get("persistent", "enabled"):
- if not mode_settings.get("onion", "password"):
- mode_settings.set("onion", "password", web.password)
- # mode_settings.save()
-
# Build the URL
- url = build_url(mode_settings, app, web)
+ url = f"http://{app.onion_host}"
print("")
if autostart_timer > 0:
@@ -490,21 +445,21 @@ def main(cwd=None):
)
print("")
- if mode_settings.get("general", "client_auth"):
- print("Give this address and HidServAuth to the sender:")
+ if mode_settings.get("general", "public"):
+ print("Give this address to the sender:")
print(url)
- print(app.auth_string)
else:
- print("Give this address to the sender:")
+ print("Give this address and private key to the sender:")
print(url)
+ print(f"Private key: {app.auth_string}")
else:
- if mode_settings.get("general", "client_auth"):
- print("Give this address and HidServAuth line to the recipient:")
+ if mode_settings.get("general", "public"):
+ print("Give this address to the recipient:")
print(url)
- print(app.auth_string)
else:
- print("Give this address to the recipient:")
+ print("Give this address and private key to the recipient:")
print(url)
+ print(f"Private key: {app.auth_string}")
print("")
print("Press Ctrl+C to stop the server")