fh_tool-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: fh_tool-cli
3
+ Version: 0.1.0
4
+ Summary: 用于本地管理 FiberHome fh_tool 接口的 Python CLI
5
+ Author: Gxxk
6
+ License-Expression: AGPL-3.0-or-later
7
+ Keywords: FiberHome,fh_tool,ONU,gateway,telecomadmin
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: System :: Networking
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: cryptography>=42.0.0
13
+ Requires-Dist: requests>=2.31.0
14
+
15
+ # fh_tool-cli
16
+
17
+ 本项目是本地管理 FiberHome `/fh_tool` 接口的 Python CLI,目标是快速管理/调整你自己的设备。
18
+
19
+ 默认推荐用 `uvx`:
20
+
21
+ ```bash
22
+ uvx --from . fh-tool --help
23
+ ```
24
+
25
+ 如果已经发布到 PyPI,使用方式会变成:
26
+
27
+ ```bash
28
+ uvx --from fh_tool-cli fh-tool --help
29
+ uvx fh_tool-cli --help
30
+ ```
31
+
32
+ 也可以在源码目录里运行:
33
+
34
+ ```bash
35
+ cd ~/fh_tool-cli
36
+ uv run fh-tool --help
37
+ ```
38
+
39
+ 下文示例中的 `fh-tool ...` 如果是在源码目录内运行,可以统一写成 `uv run fh-tool ...`。
40
+
41
+ ## 快速配置
42
+
43
+ 保存默认 IP/MAC:
44
+
45
+ ```bash
46
+ fh-tool config set --ip 192.168.1.1 --mac AABBCCDDEEFF
47
+ ```
48
+
49
+ 查看配置:
50
+
51
+ ```bash
52
+ fh-tool config show
53
+ ```
54
+
55
+ 配置文件默认在:
56
+
57
+ ```text
58
+ ~/.config/fh_tool-cli/config.json
59
+ ```
60
+
61
+ 所有命令也都可以临时传:
62
+
63
+ ```bash
64
+ fh-tool dev-info --ip 192.168.1.1 --mac AABBCCDDEEFF
65
+ ```
66
+
67
+ ## 常用命令
68
+
69
+ 低风险 probe:
70
+
71
+ ```bash
72
+ fh-tool probe
73
+ fh-tool probe --json
74
+ ```
75
+
76
+ 读取设备信息:
77
+
78
+ ```bash
79
+ fh-tool dev-info
80
+ fh-tool get-result
81
+ fh-tool get-port-mirror
82
+ fh-tool get-preconfig
83
+ ```
84
+
85
+ 读取账号类信息:
86
+
87
+ ```bash
88
+ fh-tool admin-account
89
+ fh-tool reg-account
90
+ fh-tool pppoe-account
91
+ fh-tool pwd-reg-password
92
+ ```
93
+
94
+ 打开 runtime Telnet:
95
+
96
+ ```bash
97
+ fh-tool telnet enable --yes
98
+ ```
99
+
100
+ 检查端口:
101
+
102
+ ```bash
103
+ fh-tool ports --ports 23,80,443,8080
104
+ ```
105
+
106
+ ## 22 个 `/fh_tool/api` method 覆盖
107
+
108
+ 已提供 typed command:
109
+
110
+ | func | command |
111
+ |---|---|
112
+ | `GetResult` | `fh-tool get-result` |
113
+ | `SetResult` | `fh-tool set-result --result VALUE --yes` |
114
+ | `GetPortMirror` | `fh-tool get-port-mirror` |
115
+ | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... --yes` |
116
+ | `LogDownload` | `fh-tool log-download [--output log.tar.gz]` |
117
+ | `GetDevInfo` | `fh-tool dev-info` |
118
+ | `GetAdminAccount` | `fh-tool admin-account` |
119
+ | `GetRegAccount` | `fh-tool reg-account` |
120
+ | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... --yes` |
121
+ | `GetPwdRegPassword` | `fh-tool pwd-reg-password` |
122
+ | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... --yes` |
123
+ | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz --yes` |
124
+ | `RestoreDefaultSettings` | `fh-tool restore-default-settings --yes --danger --i-know-this-can-break-my-device` |
125
+ | `UploadPrepare` | `fh-tool upload-prepare` |
126
+ | `DeviceReboot` | `fh-tool reboot --yes --danger --i-know-this-can-break-my-device` |
127
+ | `GetPreconfig` | `fh-tool get-preconfig` |
128
+ | `SetPreconfig` | `fh-tool set-preconfig --fullname ... --yes --danger` |
129
+ | `TelnetEnable` | `fh-tool telnet enable --yes` / `fh-tool telnet disable --yes --danger` |
130
+ | `GetPppoeAccount` | `fh-tool pppoe-account` |
131
+ | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... --yes --danger` |
132
+ | `CloseFHDebugLog` | `fh-tool close-fh-debug-log --yes` |
133
+ | `OpenFHDebugLog` | `fh-tool open-fh-debug-log --yes` |
134
+
135
+ raw call 入口:
136
+
137
+ ```bash
138
+ fh-tool call --func GetDevInfo
139
+ fh-tool call --func TelnetEnable --param telnet=1 --allow-risky
140
+ ```
141
+
142
+ ## upload / download endpoint
143
+
144
+ 下载 `LogDownload` 或 `DownloadFile` 返回的文件:
145
+
146
+ ```bash
147
+ fh-tool download-url --url '/fh_tool/tool_download?file=xxx.tar.gz' --output xxx.tar.gz
148
+ ```
149
+
150
+ 上传前先获取 token:
151
+
152
+ ```bash
153
+ fh-tool upload-prepare
154
+ ```
155
+
156
+ 上传 firmware/preconfig:
157
+
158
+ ```bash
159
+ fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN --yes --danger
160
+ ```
161
+
162
+ ## 风险边界
163
+
164
+ 这些命令默认不会执行,必须显式确认:
165
+
166
+ - `--yes`: 会写设备状态或创建下载文件。
167
+ - `--danger`: 高风险写入、关闭 Telnet、执行 debug script、upload。
168
+ - `--i-know-this-can-break-my-device`: 恢复出厂或重启。
169
+
170
+ 当前设备如果需要保持 Telnet 打开,不要运行:
171
+
172
+ ```bash
173
+ fh-tool telnet disable --yes --danger
174
+ ```
175
+
176
+ ## License
177
+
178
+ AGPL-3.0-or-later
@@ -0,0 +1,164 @@
1
+ # fh_tool-cli
2
+
3
+ 本项目是本地管理 FiberHome `/fh_tool` 接口的 Python CLI,目标是快速管理/调整你自己的设备。
4
+
5
+ 默认推荐用 `uvx`:
6
+
7
+ ```bash
8
+ uvx --from . fh-tool --help
9
+ ```
10
+
11
+ 如果已经发布到 PyPI,使用方式会变成:
12
+
13
+ ```bash
14
+ uvx --from fh_tool-cli fh-tool --help
15
+ uvx fh_tool-cli --help
16
+ ```
17
+
18
+ 也可以在源码目录里运行:
19
+
20
+ ```bash
21
+ cd ~/fh_tool-cli
22
+ uv run fh-tool --help
23
+ ```
24
+
25
+ 下文示例中的 `fh-tool ...` 如果是在源码目录内运行,可以统一写成 `uv run fh-tool ...`。
26
+
27
+ ## 快速配置
28
+
29
+ 保存默认 IP/MAC:
30
+
31
+ ```bash
32
+ fh-tool config set --ip 192.168.1.1 --mac AABBCCDDEEFF
33
+ ```
34
+
35
+ 查看配置:
36
+
37
+ ```bash
38
+ fh-tool config show
39
+ ```
40
+
41
+ 配置文件默认在:
42
+
43
+ ```text
44
+ ~/.config/fh_tool-cli/config.json
45
+ ```
46
+
47
+ 所有命令也都可以临时传:
48
+
49
+ ```bash
50
+ fh-tool dev-info --ip 192.168.1.1 --mac AABBCCDDEEFF
51
+ ```
52
+
53
+ ## 常用命令
54
+
55
+ 低风险 probe:
56
+
57
+ ```bash
58
+ fh-tool probe
59
+ fh-tool probe --json
60
+ ```
61
+
62
+ 读取设备信息:
63
+
64
+ ```bash
65
+ fh-tool dev-info
66
+ fh-tool get-result
67
+ fh-tool get-port-mirror
68
+ fh-tool get-preconfig
69
+ ```
70
+
71
+ 读取账号类信息:
72
+
73
+ ```bash
74
+ fh-tool admin-account
75
+ fh-tool reg-account
76
+ fh-tool pppoe-account
77
+ fh-tool pwd-reg-password
78
+ ```
79
+
80
+ 打开 runtime Telnet:
81
+
82
+ ```bash
83
+ fh-tool telnet enable --yes
84
+ ```
85
+
86
+ 检查端口:
87
+
88
+ ```bash
89
+ fh-tool ports --ports 23,80,443,8080
90
+ ```
91
+
92
+ ## 22 个 `/fh_tool/api` method 覆盖
93
+
94
+ 已提供 typed command:
95
+
96
+ | func | command |
97
+ |---|---|
98
+ | `GetResult` | `fh-tool get-result` |
99
+ | `SetResult` | `fh-tool set-result --result VALUE --yes` |
100
+ | `GetPortMirror` | `fh-tool get-port-mirror` |
101
+ | `SetPortMirror` | `fh-tool set-port-mirror --enable ... --direction ... --srcport ... --dstport ... --yes` |
102
+ | `LogDownload` | `fh-tool log-download [--output log.tar.gz]` |
103
+ | `GetDevInfo` | `fh-tool dev-info` |
104
+ | `GetAdminAccount` | `fh-tool admin-account` |
105
+ | `GetRegAccount` | `fh-tool reg-account` |
106
+ | `SetRegAccount` | `fh-tool set-reg-account --regname ... --regpwd ... --yes` |
107
+ | `GetPwdRegPassword` | `fh-tool pwd-reg-password` |
108
+ | `SetPwdRegPassword` | `fh-tool set-pwd-reg-password --password ... --yes` |
109
+ | `DownloadFile` | `fh-tool download-file --file-name /var/... --output out.tar.gz --yes` |
110
+ | `RestoreDefaultSettings` | `fh-tool restore-default-settings --yes --danger --i-know-this-can-break-my-device` |
111
+ | `UploadPrepare` | `fh-tool upload-prepare` |
112
+ | `DeviceReboot` | `fh-tool reboot --yes --danger --i-know-this-can-break-my-device` |
113
+ | `GetPreconfig` | `fh-tool get-preconfig` |
114
+ | `SetPreconfig` | `fh-tool set-preconfig --fullname ... --yes --danger` |
115
+ | `TelnetEnable` | `fh-tool telnet enable --yes` / `fh-tool telnet disable --yes --danger` |
116
+ | `GetPppoeAccount` | `fh-tool pppoe-account` |
117
+ | `SetFHDebugLog` | `fh-tool set-fh-debug-log --module tr069 --data ... --yes --danger` |
118
+ | `CloseFHDebugLog` | `fh-tool close-fh-debug-log --yes` |
119
+ | `OpenFHDebugLog` | `fh-tool open-fh-debug-log --yes` |
120
+
121
+ raw call 入口:
122
+
123
+ ```bash
124
+ fh-tool call --func GetDevInfo
125
+ fh-tool call --func TelnetEnable --param telnet=1 --allow-risky
126
+ ```
127
+
128
+ ## upload / download endpoint
129
+
130
+ 下载 `LogDownload` 或 `DownloadFile` 返回的文件:
131
+
132
+ ```bash
133
+ fh-tool download-url --url '/fh_tool/tool_download?file=xxx.tar.gz' --output xxx.tar.gz
134
+ ```
135
+
136
+ 上传前先获取 token:
137
+
138
+ ```bash
139
+ fh-tool upload-prepare
140
+ ```
141
+
142
+ 上传 firmware/preconfig:
143
+
144
+ ```bash
145
+ fh-tool upload --action preconfig --file sysinfo_conf --sessionid TOKEN --yes --danger
146
+ ```
147
+
148
+ ## 风险边界
149
+
150
+ 这些命令默认不会执行,必须显式确认:
151
+
152
+ - `--yes`: 会写设备状态或创建下载文件。
153
+ - `--danger`: 高风险写入、关闭 Telnet、执行 debug script、upload。
154
+ - `--i-know-this-can-break-my-device`: 恢复出厂或重启。
155
+
156
+ 当前设备如果需要保持 Telnet 打开,不要运行:
157
+
158
+ ```bash
159
+ fh-tool telnet disable --yes --danger
160
+ ```
161
+
162
+ ## License
163
+
164
+ AGPL-3.0-or-later
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fh_tool-cli"
7
+ version = "0.1.0"
8
+ description = "用于本地管理 FiberHome fh_tool 接口的 Python CLI"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "AGPL-3.0-or-later"
12
+ authors = [
13
+ { name = "Gxxk" },
14
+ ]
15
+ keywords = ["FiberHome", "fh_tool", "ONU", "gateway", "telecomadmin"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Topic :: System :: Networking",
19
+ ]
20
+ dependencies = [
21
+ "cryptography>=42.0.0",
22
+ "requests>=2.31.0",
23
+ ]
24
+
25
+ [project.scripts]
26
+ fh-tool = "fh_tool_cli.cli:main"
27
+ fh_tool-cli = "fh_tool_cli.cli:main"
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Local CLI for FiberHome fh_tool endpoints."""
2
+
3
+ __version__ = "0.1.0"