diff --git a/config.template b/config.template index ef684f9..7337fc0 100644 --- a/config.template +++ b/config.template @@ -310,6 +310,10 @@ enable_runShellCmd = False # if runShellCmd and you think it is safe to allow the x: command to run # direct shell command handler the x: command in DMs allowXcmd = False +# Enable 2 factor authentication for x: commands +2factor_enabled = True +# time in seconds to wait for the correct 2FA answer +2factor_timeout = 100 [smtp] # enable or disable the SMTP module diff --git a/modules/filemon.py b/modules/filemon.py index 79c6438..5eb0d4f 100644 --- a/modules/filemon.py +++ b/modules/filemon.py @@ -89,9 +89,8 @@ def call_external_script(message, script="script/runShell.sh"): logger.warning(f"FileMon: Error calling external script: {e}") return None -xCmd2factor = True # Enable 2FA for x: commands + waitingXroom = {} # {message_from_id: (expected_answer, original_command, timestamp)} -xCmd2factor_timeout = 100 # seconds def handleShellCmd(message, message_from_id, channel_number, isDM, deviceID): if not allowXcmd: return "x: command is disabled" @@ -102,7 +101,7 @@ def handleShellCmd(message, message_from_id, channel_number, isDM, deviceID): return "x: command not authorized in group chat" # 2FA logic - if xCmd2factor: + if xCmd2factorEnabled: timeNOW = datetime.utcnow() # If user is waiting for 2FA, treat message as answer if message_from_id in waitingXroom: diff --git a/modules/settings.py b/modules/settings.py index ab557fd..60ec670 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -373,6 +373,8 @@ try: news_random_line_only = config['fileMon'].getboolean('news_random_line', False) # default False enable_runShellCmd = config['fileMon'].getboolean('enable_runShellCmd', False) # default False allowXcmd = config['fileMon'].getboolean('allowXcmd', False) # default False + xCmd2factorEnabled = config['fileMon'].getboolean('2factor_enabled', False) # default False + xCmd2factor_timeout = config['fileMon'].getint('2factor_timeout', 100) # default 100 seconds # games game_hop_limit = config['games'].getint('game_hop_limit', 5) # default 5 hops diff --git a/modules/system.py b/modules/system.py index 876dcb1..2edc9ff 100644 --- a/modules/system.py +++ b/modules/system.py @@ -49,7 +49,6 @@ def cleanup_memory(): if cleaned_count > 0: logger.debug(f"System: Cleaned up {cleaned_count} stale entries from waitingXroom") - # Clean up old seenNodes entries if 'seenNodes' in globals(): initial_count = len(seenNodes)