mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
Use separate tweak menus for clients and servers
Former-commit-id: 92a7ce68f150aa223bc5a78ba02dd7cb7c07317d Former-commit-id: 838381c35f3fec2a8780772bef8fcac33e7baac1
This commit is contained in:
+3
-5
@@ -829,10 +829,9 @@ if __name__ == "__main__":
|
|||||||
read_shortcut()
|
read_shortcut()
|
||||||
elif arguments[0] == 'tweak':
|
elif arguments[0] == 'tweak':
|
||||||
success_flag = True
|
success_flag = True
|
||||||
from stweak import menu_repeat
|
from stweak import global_menu
|
||||||
menu_repeat(False)
|
global_menu(device_type, 'configuration options:')
|
||||||
|
|
||||||
# PORT START ARGS-SERVER
|
|
||||||
# server arguments
|
# server arguments
|
||||||
else:
|
else:
|
||||||
if arg_count < 1:
|
if arg_count < 1:
|
||||||
@@ -848,11 +847,10 @@ if __name__ == "__main__":
|
|||||||
elif arg_count == 1 and arguments[0] == 'tweak':
|
elif arg_count == 1 and arguments[0] == 'tweak':
|
||||||
success_flag = True
|
success_flag = True
|
||||||
from stweak import global_menu
|
from stweak import global_menu
|
||||||
global_menu(False)
|
global_menu(device_type, 'configuration options:')
|
||||||
elif arg_count > 2 and arguments[1] in ('add', 'del'):
|
elif arg_count > 2 and arguments[1] in ('add', 'del'):
|
||||||
success_flag = True
|
success_flag = True
|
||||||
whitelist_manage(arguments[2])
|
whitelist_manage(arguments[2])
|
||||||
# PORT END ARGS-SERVER
|
|
||||||
|
|
||||||
if arg_count > 0 and success_flag == 0 and arguments[0] != 'sync':
|
if arg_count > 0 and success_flag == 0 and arguments[0] != 'sync':
|
||||||
if device_type == 'client' and arguments[0] not in ('help', '-h', 'version', '-v', 'license'):
|
if device_type == 'client' and arguments[0] not in ('help', '-h', 'version', '-v', 'license'):
|
||||||
|
|||||||
+25
-23
@@ -230,32 +230,25 @@ def quick_unlock_config(_default):
|
|||||||
return _enabled
|
return _enabled
|
||||||
|
|
||||||
|
|
||||||
# continually shows the tweak menu after each change until the user manually exits
|
|
||||||
def menu_repeat(_post_setup):
|
|
||||||
while True:
|
|
||||||
if global_menu(_post_setup):
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
# runs secondary configuration menu
|
# runs secondary configuration menu
|
||||||
def global_menu(_post_setup):
|
def global_menu(_device_type, _top_message):
|
||||||
|
while True:
|
||||||
# curses initialization
|
# curses initialization
|
||||||
noecho()
|
noecho()
|
||||||
cbreak()
|
cbreak()
|
||||||
stdscr.keypad(True)
|
stdscr.keypad(True)
|
||||||
|
|
||||||
_options, _choice, _term_message, _return_val = [], 4, False, False
|
_options, _choice, _term_message, _exit_signal = ['change device/synchronization types'], 0, False, False
|
||||||
try:
|
try:
|
||||||
if not _post_setup:
|
if _device_type == 'client':
|
||||||
_options.extend(['change device/synchronization types', 'change gpg key', 're-configure ssh(ync)',
|
_options.extend(['change gpg key', 're-configure ssh(ync)', 'change device name',
|
||||||
'change device name'])
|
'[OPTIONAL, RECOMMENDED] set custom text editor',
|
||||||
_message, _choice = 'all configuration options:', 0
|
'[OPTIONAL, RECOMMENDED] enable/disable quick-unlock', '[OPTIONAL, NOT IMPLEMENTED] su security mode',
|
||||||
_options.extend(['[OPTIONAL, RECOMMENDED] set custom text editor',
|
'[OPTIONAL, NOT IMPLEMENTED] extensions and updates'])
|
||||||
'[OPTIONAL, RECOMMENDED] enable/disable quick-unlock',
|
else:
|
||||||
'[OPTIONAL, NOT IMPLEMENTED] su security mode',
|
_options.extend(['manage quick-unlock'])
|
||||||
'[OPTIONAL, NOT IMPLEMENTED] extensions and updates', 'exit/done'])
|
_options.extend(['exit/done'])
|
||||||
_message = 'required configuration complete - additional configuration options:'
|
_choice += curses_radio(_options, _top_message)
|
||||||
_choice += curses_radio(_options, _message)
|
|
||||||
|
|
||||||
if _choice == 0:
|
if _choice == 0:
|
||||||
_dev_sync_types = install_type()
|
_dev_sync_types = install_type()
|
||||||
@@ -265,10 +258,17 @@ def global_menu(_post_setup):
|
|||||||
# if no device id is set
|
# if no device id is set
|
||||||
if not listdir(f"{home}/.config/sshyp/devices"):
|
if not listdir(f"{home}/.config/sshyp/devices"):
|
||||||
dev_id_config(_ip, _username_ssh, _port)
|
dev_id_config(_ip, _username_ssh, _port)
|
||||||
|
_device_type = _dev_sync_types[0]
|
||||||
elif _choice == 1:
|
elif _choice == 1:
|
||||||
|
if _device_type == 'client':
|
||||||
gpg_config()
|
gpg_config()
|
||||||
|
else:
|
||||||
|
pass # TODO implement quick-unlock management
|
||||||
elif _choice == 2:
|
elif _choice == 2:
|
||||||
|
if _device_type == 'client':
|
||||||
ssh_config()
|
ssh_config()
|
||||||
|
else:
|
||||||
|
_exit_signal = True
|
||||||
elif _choice == 3:
|
elif _choice == 3:
|
||||||
if not sshyp_data.has_section('SSHYNC'):
|
if not sshyp_data.has_section('SSHYNC'):
|
||||||
ssh_config()
|
ssh_config()
|
||||||
@@ -279,17 +279,19 @@ def global_menu(_post_setup):
|
|||||||
elif _choice == 5:
|
elif _choice == 5:
|
||||||
_enabled = quick_unlock_config(False)
|
_enabled = quick_unlock_config(False)
|
||||||
if _enabled == 'true':
|
if _enabled == 'true':
|
||||||
|
# TODO update for future menu-based quick-unlock management
|
||||||
_term_message = ("\nquick-unlock has been enabled client-side - in order for this feature to function,"
|
_term_message = ("\nquick-unlock has been enabled client-side - in order for this feature to function,"
|
||||||
"\nyou must first log in to the sshyp server and run:\n\nsshyp whitelist setup (if not"
|
"\nyou must first log in to the sshyp server and run:\n\nsshyp whitelist setup (if not"
|
||||||
" already done)\nsshyp whitelist add "
|
" already done)\nsshyp whitelist add "
|
||||||
f"'{listdir(f'{home}/.config/sshyp/devices')[0].rstrip()}'\n")
|
f"'{listdir(f'{home}/.config/sshyp/devices')[0].rstrip()}'\n")
|
||||||
elif _choice == 8:
|
elif _choice == 8:
|
||||||
_return_val = True
|
_exit_signal = True
|
||||||
curses_terminate(_term_message)
|
curses_terminate(_term_message)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
curses_terminate(False)
|
curses_terminate(False)
|
||||||
_return_val = True
|
_exit_signal = True
|
||||||
return _return_val
|
if _exit_signal:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
# runs initial configuration wizard
|
# runs initial configuration wizard
|
||||||
@@ -365,7 +367,7 @@ def initial_setup():
|
|||||||
f'"{_clipboard_package}" is installed\u001b[0m')
|
f'"{_clipboard_package}" is installed\u001b[0m')
|
||||||
# PORT END CLIPTOOL
|
# PORT END CLIPTOOL
|
||||||
|
|
||||||
menu_repeat(True)
|
global_menu(_dev_sync_types[0], 'additional configuration options:')
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# cleanly exit curses
|
# cleanly exit curses
|
||||||
|
|||||||
Reference in New Issue
Block a user