Skip to main content

用于本地管理 FiberHome fh_tool 接口的 Python CLI

Project description

fh_tool-cli

本项目是本地管理 FiberHome /fh_tool 接口的 Python CLI,目标是快速管理/调整你自己的设备。

默认推荐用 uvx

uvx --from . fh-tool --help

如果已经发布到 PyPI,使用方式会变成:

uvx --from fh_tool-cli fh-tool --help
uvx fh_tool-cli --help

也可以在源码目录里运行:

cd ~/fh_tool-cli
uv run fh-tool --help

下文示例中的 fh-tool ... 如果是在源码目录内运行,可以统一写成 uv run fh-tool ...

快速配置

保存默认 IP/MAC:

fh-tool config set --ip 192.168.1.1 --mac AABBCCDDEEFF

查看配置:

fh-tool config show

配置文件默认在:

~/.config/fh_tool-cli/config.json

所有命令也都可以临时传:

fh-tool dev-info --ip 192.168.1.1 --mac AABBCCDDEEFF

常用命令

低风险 probe:

fh-tool probe
fh-tool probe --json

读取设备信息:

fh-tool dev-info
fh-tool get-result
fh-tool get-port-mirror
fh-tool get-preconfig

读取账号类信息:

fh-tool admin-account
fh-tool reg-account
fh-tool pppoe-account
fh-tool pwd-reg-password

打开 runtime Telnet:

fh-tool telnet enable --yes

检查端口:

fh-tool ports --ports 23,80,443,8080

22 个 /fh_tool/api method 覆盖

已提供 typed command:

func command
GetResult fh-tool get-result
SetResult fh-tool set-result --result VALUE --yes
GetPortMirror fh-tool get-port-mirror
SetPortMirror fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... --yes
LogDownload fh-tool log-download [--output log.tar.gz]
GetDevInfo fh-tool dev-info
GetAdminAccount fh-tool admin-account
GetRegAccount fh-tool reg-account
SetRegAccount fh-tool set-reg-account --regname ... --regpwd ... --yes
GetPwdRegPassword fh-tool pwd-reg-password
SetPwdRegPassword fh-tool set-pwd-reg-password --password ... --yes
DownloadFile fh-tool download-file --file-name /var/... --output out.tar.gz --yes
RestoreDefaultSettings fh-tool restore-default-settings --yes --danger --i-know-this-can-break-my-device
UploadPrepare fh-tool upload-prepare
DeviceReboot fh-tool reboot --yes --danger --i-know-this-can-break-my-device
GetPreconfig fh-tool get-preconfig
SetPreconfig fh-tool set-preconfig --fullname ... --yes --danger
TelnetEnable fh-tool telnet enable --yes / fh-tool telnet disable --yes --danger
GetPppoeAccount fh-tool pppoe-account
SetFHDebugLog fh-tool set-fh-debug-log --module tr069 --data ... --yes --danger
CloseFHDebugLog fh-tool close-fh-debug-log --yes
OpenFHDebugLog fh-tool open-fh-debug-log --yes

raw call 入口:

fh-tool call --func GetDevInfo
fh-tool call --func TelnetEnable --param telnet=1 --allow-risky

upload / download endpoint

下载 LogDownloadDownloadFile 返回的文件:

fh-tool download-url --url '/fh_tool/tool_download?file=xxx.tar.gz' --output xxx.tar.gz

上传前先获取 token:

fh-tool upload-prepare

上传 firmware/preconfig:

fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN --yes --danger

风险边界

这些命令默认不会执行,必须显式确认:

  • --yes: 会写设备状态或创建下载文件。
  • --danger: 高风险写入、关闭 Telnet、执行 debug script、upload。
  • --i-know-this-can-break-my-device: 恢复出厂或重启。

当前设备如果需要保持 Telnet 打开,不要运行:

fh-tool telnet disable --yes --danger

License

AGPL-3.0-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fh_tool_cli-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fh_tool_cli-0.1.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file fh_tool_cli-0.1.0.tar.gz.

File metadata

  • Download URL: fh_tool_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fh_tool_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a028dc71362049074c4f9f9a4edb1c4b9444dd52db03e85be0167d1ecee22baa
MD5 6188647d4f4fa225fd46b3b67a04118e
BLAKE2b-256 a019603fd7f480907375d1577dcd8fbf78af5aaddc23cab764035b8fd54760ef

See more details on using hashes here.

File details

Details for the file fh_tool_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fh_tool_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fh_tool_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd1791b5c8438809b230048f01d97055c783bda9144b2db69bfe23623423a012
MD5 590ac21aee49bbb42cf5ed6127e4faf3
BLAKE2b-256 b87afc8cfda2fe1819c2a81f50dd54fa19b3726af8c2ee172e2d30d6ea964f80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page