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.1.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.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fh_tool_cli-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 aee8e3e2a2f825ee8e85ddb35f31732416905ed25a7d527b224db841c192d4fd
MD5 889e62d44f477c799787ac4cea26a8c4
BLAKE2b-256 8d01c4f953921af0d12d27a1a7899cb423882983f77f8537bdd280dfda56aff9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fh_tool_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 465ca14226b84a0f7ddbb4ca99582b10c31ec2884fe00a8be806c6fa4f77cf8d
MD5 717ce9a9793658d2fc0a5f3379995b53
BLAKE2b-256 c06e576d9ad9ce7fbaa153f7990544f6e317f1d83341e314fae50cf726e67664

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