Add live Disable Telnet action to Web Access Control
Adds a standalone DISABLE TELNET button (no enable counterpart, per requirement) alongside the existing HTTPS enable/disable toggle. Reuses the same target/concurrency controls and SSH push flow, backed by a new "disable_telnet" action mapped to "no ip telnet" on the switch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CLfUJoQTaUePx1m1d2v2j9
This commit is contained in:
@@ -89,16 +89,22 @@ def api_web_access():
|
||||
ip = data.get("ip", "").strip()
|
||||
username = data.get("username", "").strip()
|
||||
password = data.get("password", "").strip()
|
||||
action = data.get("action", "") # "enable" or "disable"
|
||||
action = data.get("action", "") # "enable", "disable", or "disable_telnet"
|
||||
|
||||
commands = {
|
||||
"enable": "ip http secure-server",
|
||||
"disable": "no ip http secure-server",
|
||||
"disable_telnet": "no ip telnet",
|
||||
}
|
||||
|
||||
if not ip or not username or not password:
|
||||
return jsonify({"ok": False, "error": "Missing IP or credentials"}), 400
|
||||
if action not in ("enable", "disable"):
|
||||
if action not in commands:
|
||||
return jsonify({"ok": False, "error": "Invalid action"}), 400
|
||||
|
||||
print(f"[web-access] {action} {ip} user={username!r} pass_len={len(password)}", flush=True)
|
||||
|
||||
cmd = "ip http secure-server" if action == "enable" else "no ip http secure-server"
|
||||
cmd = commands[action]
|
||||
|
||||
try:
|
||||
sock = socket.create_connection((ip, 22), timeout=10)
|
||||
|
||||
Reference in New Issue
Block a user