返回资讯中心
外部精选
软件工程
#开发者实时流

开发者发布 Sky Hub 路由器的 Terraform provider,通过模拟管理界面操作

来源标题:Show HN: Terraform provider for my UK ISP's home router (Sky Hub, no API)

一个非官方 Terraform provider 已发布,用于管理 Sky Hub(Sagemcom SR200 系列)家庭路由器。该路由器没有 API,provider 通过 Go 库 skyhub 驱动其管理网页界面(HTTP Digest 认证、HTML 表单、每页 CSRF sessionKey)来操作。项目仅能在局域网内运行,且因界面未公开,固件更新可能导致失效,作者提示使用风险自负。

Hacker News 最新sedak2026/11/30 · 今天12 分钟阅读

以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。

Here's a review of the post, plus a few concrete fixes.

What works well

  • Framing is honest. The disclaimer, the "use at your own risk," the WEP-after-save warning, and the backup-up-front advice set expectations correctly. This is the kind of candor HN rewards.
  • The "no API" angle is the story. You lead with it, which is right — a provider driving a Digest-auth HTML UI with per-page CSRF is genuinely interesting engineering.
  • Concrete details beat hand-waving. The serialised client, the singleton id = "default", the write-only psk_wo / psk_wo_version pattern, the bitmask-vs-rendered-checkbox subtlety — these are the parts people will ask about in comments. You pre-empt them.
  • The code samples are short enough to skim.

Problems to fix

1. The code block is broken. In the body as pasted, the HCL is missing closing braces on almost every resource and the blocks run together (e.g. the skyhub_dhcp_reservation and skyhub_service blocks never close, and provider/terraform blocks at the end are truncated). If that's how it will render on HN, it looks careless. Re-check the fenced block before posting — every resource needs its closing }, and the terraform { required_providers { ... } } at the bottom needs both closers.

2. The WEP warning appears twice and contradicts slightly. The disclaimer says it "blocks WPA2-only devices until the hub is rebooted"; later you say "the cause is not confirmed (the hub's own firmware, or something this tooling pokes at the wrong moment)." That second hedged sentence is more honest and belongs in the disclaimer, while the later paragraph can just cover recovery. As written, a reader wonders whether your own tool causes it. Pick one place to say "cause unconfirmed" and keep it.

3. "Nothing in this provider reboots… factory-resets or upgrades the hub" vs. the WEP paragraph. You say recovery is "outside this provider, with the skyhub CLI's reboot." Then the disclaimer says a bad apply can leave the hub "needing a factory reset." That's fine, but the two statements sit far apart. Consider a one-line pointer in the disclaimer: "Recovery is manual (CLI reboot or hub UI); see below."

4. The skyhub_lan restart behaviour is buried. "When a skyhub_lan change restarts the hub onto a new address, the provider keeps the planned values, warns, and does not read back" — this is surprising and important. Put it near the top of the caveats, not in the middle of a paragraph about skyhub_ethernet.

5. Minor copy issues:

  • "Address reservation (MAC to IPv4)" — fine, but the name max of 17 characters is oddly specific; a reader may wonder why. One clause ("the hub truncates longer labels") would help, if true.
  • "The hub renders every rule as enabled; the provider reads the real flag from the hub's stored bitmask." — good, keep.
  • "throwaway entries only" for the live test — clarify what "entries" means (DHCP reservations? services?). A comment in the test line would do.
  • Registry version = "~> 0.4" while you refer to 0.4 docs — fine, but state the current release explicitly somewhere ("v0.4.x").
  • The go install . comment says it builds into $GOPATH/bin; the dev_overrides path is /home/fred/go/bin. Consistent enough, but a reader on a different machine will trip. Say "adjust the path to your $GOPATH/bin."

Suggested restructuring

  1. One-sentence pitch: Terraform provider for a router that has no API.
  2. How it works (Digest + forms + CSRF, serialised client, LAN-only).
  3. Honest disclaimer — including the WEP risk and "cause unconfirmed," and the backup advice.
  4. Example HCL (fixed).
  5. Key design notes: singletons, firewall rule identity, write-only secrets, the skyhub_lan new-address behaviour.
  6. Install / dev build / tests (with the $GOPATH/bin caveat).

One thing you might get asked

"Why not just call the CLI?" Worth a single sentence: the provider gives plan/apply, drift detection and state, which the CLI doesn't. If the skyhub CLI already wraps the same library, say so — it strengthens the "this is a proper tool, not a scraper" point.

Bottom line

The substance is strong and HN-appropriate. Fix the truncated HCL block (the biggest credibility hit), consolidate the WEP caveat into one honest statement, and move the skyhub_lan-new-address behaviour up. Those three changes turn a good post into a clean one.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →