Tencent Cloud Lighthouse firewall updater with CLI and TUI.
Project description
lighthouse-fw
一个面向 Tencent Cloud Lighthouse 防火墙白名单更新 的 Python 包,支持:
uvx lighthouse-fw直接进入 TUIlhfw/uv run lhfw ...使用 CLI- 管理
credential、server、managed_rules - dry-run diff 预览 + apply 前显式确认
- Windows / Linux / macOS 跨平台配置布局
- 密钥优先系统钥匙串,无法使用时回退到本地加密文件
English summary
lighthouse-fw is a Python package for managing Tencent Cloud Lighthouse firewall allowlist rules. It provides a default TUI entry point via uvx lighthouse-fw, a full CLI via lhfw, dry-run diff previews, explicit confirmation before apply, legacy config import, and a GitHub Actions + PyPI release path.
安装与运行
1. 直接用 uvx
默认进入 TUI:
uvx lighthouse-fw
直接运行 CLI 子命令:
uvx lighthouse-fw doctor
uvx lighthouse-fw run
2. 安装成工具命令
uv tool install lighthouse-fw
lhfw doctor
lhfw tui
3. 仓库内本地运行
uv run lhfw doctor
uv run lhfw tui
默认行为
uvx lighthouse-fw:默认进入 TUIlhfw doctor:默认检查本地环境、密钥后端,以及 credential 级 腾讯云凭据 / API 可达性lhfw run:不带筛选条件时,默认运行所有 enabled 的 serverlhfw run --apply:会先做 diff 预览,再要求显式确认
配置模型
当前包的持久化配置由三部分组成:
- 普通配置:
config.toml - 密钥:优先系统钥匙串;无安全后端时回退到本地加密文件
secrets.bin - 本地口令/密钥文件:
secrets.key
server 支持:
enabled状态- 多个自由标签
tags - 完整
managed_rules
每条 managed_rules 支持:
protocolportcidractiondescriptionreplace_existing_same_port
常用 CLI
初始化
lhfw init
查看配置
lhfw config show
lhfw config history
设置 defaults
lhfw config set-defaults `
--endpoint lighthouse.tencentcloudapi.com `
--request-timeout-seconds 4 `
--history-limit 20 `
--ip-source https://myip.ipip.net/s `
--ip-source http://whois.pconline.com.cn/ipJson.jsp
管理 credential
lhfw credential set work --region ap-singapore
lhfw credential set-secret work
lhfw credential list
如果你想继续使用环境变量,也可以只存 metadata:
lhfw credential set work `
--region ap-singapore `
--secret-id-env TENCENT_SECRET_ID `
--secret-key-env TENCENT_SECRET_KEY
管理 server
lhfw server set sg-prod `
--instance-id lhins-123456 `
--credential work `
--tag prod `
--tag sg `
--enabled
管理 rules
lhfw server rule-add sg-prod `
--protocol TCP `
--port 22 `
--cidr AUTO `
--description "SSH"
lhfw server rule-list sg-prod
预览和执行
预览全部 enabled server:
lhfw run
按 tag 过滤:
lhfw run --tag prod --tag sg
实际写入:
lhfw run --apply
TUI 能力
当前默认 TUI 已支持:
- server 增删改
- credential 增删改
- 在 server 编辑界面内完整维护
managed_rules - 批量选中 server
- 按 tag 批量选中
- diff 预览
- apply 前确认
- history 查看
doctor诊断入口
从旧脚本迁移
旧的 tencent_lighthouse_fw.toml 不再作为长期直接运行格式保留,但支持导入:
lhfw import-legacy .\tencent_lighthouse_fw.toml
导入后会迁移:
defaultscredentials.*[[servers]]managed_rules
旧配置中的环境变量名也会被保留为新的 credential metadata。
安全说明
- 优先使用系统钥匙串
- 如果当前平台没有安全 keyring backend,会回退到本地加密文件
credential在 TUI 中默认隐藏,按需临时显示doctor默认是只读检查,不会逐台 server 修改任何东西
开发与测试
uv run python -m unittest discover -s tests -v
uv run lhfw doctor
发布
项目按 PyPI 发布路径设计:
- 包名:
lighthouse-fw - 命令名:
lhfw - 版本 tag:
v1.2.3 - 认证:GitHub OIDC Trusted Publishing
推送版本 tag 后,GitHub Actions 会自动构建并发布到 PyPI。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lighthouse_fw-0.1.0.tar.gz.
File metadata
- Download URL: lighthouse_fw-0.1.0.tar.gz
- Upload date:
- Size: 33.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b0677ea988a545c2ff3496cf0d36d35c7fe820ac8358b205c91e27796f9c6cd
|
|
| MD5 |
6ab12fe06ceaed72302025a6ca1a78a1
|
|
| BLAKE2b-256 |
38445fa026fe02248f706e036c7a1d653a3f5d09c30de3e9764001a0f55b6b83
|
Provenance
The following attestation bundles were made for lighthouse_fw-0.1.0.tar.gz:
Publisher:
lighthouse-fw-publish.yml on star-plan/tencent-lighthouse-fw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lighthouse_fw-0.1.0.tar.gz -
Subject digest:
8b0677ea988a545c2ff3496cf0d36d35c7fe820ac8358b205c91e27796f9c6cd - Sigstore transparency entry: 1409679658
- Sigstore integration time:
-
Permalink:
star-plan/tencent-lighthouse-fw@92868f7c21aaab4a677790bf1854b7008f000126 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
lighthouse-fw-publish.yml@92868f7c21aaab4a677790bf1854b7008f000126 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lighthouse_fw-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lighthouse_fw-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
442e3c86cb967a5a74353a98df356ceed5159f51c958d2953a8d2791859a1f9e
|
|
| MD5 |
9a9a41db99020bc7dd13f178a47f70a1
|
|
| BLAKE2b-256 |
d06a48843cdb73eedb745b93ca6d5bb9d58bd7a273a431d8e5306ab9bde6e457
|
Provenance
The following attestation bundles were made for lighthouse_fw-0.1.0-py3-none-any.whl:
Publisher:
lighthouse-fw-publish.yml on star-plan/tencent-lighthouse-fw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lighthouse_fw-0.1.0-py3-none-any.whl -
Subject digest:
442e3c86cb967a5a74353a98df356ceed5159f51c958d2953a8d2791859a1f9e - Sigstore transparency entry: 1409679665
- Sigstore integration time:
-
Permalink:
star-plan/tencent-lighthouse-fw@92868f7c21aaab4a677790bf1854b7008f000126 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/star-plan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
lighthouse-fw-publish.yml@92868f7c21aaab4a677790bf1854b7008f000126 -
Trigger Event:
push
-
Statement type: