Skip to content

Add telnet control (set_telnet/telnet_enabled + CLI)#1

Merged
widgetii merged 1 commit into
masterfrom
add-telnet-control
Jun 18, 2026
Merged

Add telnet control (set_telnet/telnet_enabled + CLI)#1
widgetii merged 1 commit into
masterfrom
add-telnet-control

Conversation

@widgetii

Copy link
Copy Markdown
Member

Summary

Adds control of the built-in Dahua telnet server via the DHIP binary protocol (TCP 5000), mirroring the flow in the open_telnet.sh reference script but using the existing configManager.setConfig machinery instead of HTTP RPC2.

Verified on hardware

Device: 10.216.128.118 (SD-2N-4G-class camera), admin / admin54321.

Action Result
set_telnet(True) port 23 opened (confirmed with nc -zv)
set_telnet(False) port 23 closed (connection refused)
round-trip read telnet_enabled() matches written state

Before/after InnerServer config read back from the device:

before: {'Telnet': {'Enable': False}}
after:  {'Telnet': {'Enable': True}}

Public API

cam.set_telnet(True)        # enable
cam.set_telnet(False)       # disable
cam.telnet_enabled()        # -> bool
cam.get_inner_server_config()  # raw InnerServer table

set_telnet does a read-modify-write of InnerServer.Telnet so sibling subkeys (SSH, FTP, ...) are preserved.

CLI

dhip HOST telnet        # prints on / off
dhip HOST telnet on     # enable
dhip HOST telnet off    # disable

Sync / async

Mirrored in both DahuaClient (sync) and AsyncDahuaClient (async), per the CLAUDE.md convention.

Tests

  • tests/test_dahua.TestTelnet.test_set_telnet_read_modify_write — fake-server round-trip; verifies the SSH subkey is preserved across enable/disable.
  • python -m unittest discover -s tests — 30 passed
  • python tests/test_loopback.py — OK

Checklist

  • python -m unittest discover -s tests passes; tests/test_loopback.py passes.
  • New public API has a test and a CLI flag.
  • Sync and async surfaces stay consistent.
  • No new third-party dependencies; no secrets in code.
  • Verified on hardware (model/firmware noted above).

Verified on hardware (SD-2N-4G, firmware 30.13...R):
- set_telnet(True) opens port 23, set_telnet(False) closes it
- Read-modify-write preserves other InnerServer subkeys (SSH, FTP, etc.)
- Sync + async surfaces, CLI subcommand, unit test
@widgetii widgetii merged commit 9099fef into master Jun 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant