Skip to content

feat(nodes): edit XHTTP link options as fields - #542

Merged
Zakkaus merged 5 commits into
mainfrom
feat/xhttp-extra
Oct 11, 2026
Merged

Zakkaus merged 5 commits into
mainfrom
feat/xhttp-extra

Conversation

@Glassyiris

@Glassyiris Glassyiris commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

honk accepts XHTTP options in a vless or trojan link's extra JSON, but the node dialog only offered the raw link, so changing padding, headers, POST pacing or a download peer meant hand-editing percent-encoded JSON. An edited link that honk cannot read was also written to the source anyway: honk's parser drops such a node entry with only a warning, so the reload succeeded and the node silently disappeared. Adding a node with a link over the API's 8192-character limit failed only at the backend.

How I fixed it

src/dae/xhttp.ts reads an XHTTP link into fields and writes back only the parameters whose value changed, keeping every other byte, unknown extra members and the link unchanged when nothing changed; links it cannot represent exactly are left to the raw field. A lazily loaded XhttpOptions disclosure in the add and edit node dialogs edits mode, path, host, headers, padding, POST pacing and the download peer through it. Before the source write, an edited link is checked alone with POST /config/validate in syntax mode, and any error, or any warning whose code is not legacy-*, refuses it with honk's reason; creation refuses links over 8192 characters. The check and the source edit share nodeKey, which quotes a node named mux: honk rejects a bare mux: line as the removed standalone setting, so the check refused valid edits of such a node and a rename to mux broke the source. Strings are added to en, zh-CN and zh-TW, with docs/pages*.md and a changelog fragment.

Verified

pnpm typecheck, pnpm lint, pnpm check:i18n, pnpm format:check and pnpm check:gen pass. check:size passed locally but CI measured the startup paths at 238517 and 342247 bytes, over the 238300 and 341850 limits, because the startup paths carry the largest language catalogue and the new strings add to it; the second commit raises startupLogin to 238700 and startupActivity to 342450. pnpm vitest run: 3760 passed, 1 failed (view.test.ts "gives an expiry to the minute…"), which fails identically on main with this machine's locale data; the new nodes.test.ts mux case fails with nodeKey replaced by quoteName. playwright test e2e/nodes.spec.ts on Chromium: 89 passed on the final head; together with e2e/a11y.spec.ts, 148 passed before the last commit. Against a local honk-core (mock eBPF, native_api serving dist/), a node added through the fields was written as expected, an edit to xPaddingBytes: 0-10 was refused with "XHTTP xPaddingBytes must stay within 1-8192" and left the source untouched, and a valid edit was saved. Not run: the full e2e suite, WebKit/Firefox, screenshots of the new fields. The legacy-* rule and the per-field honk messages come from Glassyiris/honk#140, merged into feat/native-api; with an older honk the guard still refuses skipped links, but the range message is the generic one. A matching doona-docs change has not been opened.

Submitted and answered for by (Human responsible, GitHub username): @Glassyiris


Check only claims that are true. A false claim closes the pull request.

  • I understand this change and will answer for every line. An AI cannot answer for me.
  • This branch is based on the current main.
  • Each commit contains one coherent change with an English type(scope): subject and a short English body.
  • I ran the applicable CI gates in CONTRIBUTING.md; the Verified section records the commands, results and any checks I could not complete.
  • I updated the strings in en.json and in every complete language's catalogue when I changed interface text.
  • I attached light and dark screenshots when I changed the interface appearance.
  • I ran pnpm gen:api and pnpm check:gen when I changed the API contract.
  • I checked the boxes above without reading them.
  • I am an AI agent, and this content was submitted without human review.

@Glassyiris

Copy link
Copy Markdown
Collaborator Author

Companion honk change: Glassyiris/honk#140 (static rejection reasons for node/provider creation and the documented legacy-* warning rule this dialog's edit check relies on).

@Glassyiris
Glassyiris marked this pull request as ready for review October 11, 2026 13:42
@Glassyiris
Glassyiris requested a review from Zakkaus as a code owner October 11, 2026 13:42
@Glassyiris
Glassyiris enabled auto-merge (squash) October 11, 2026 14:05
@Glassyiris
Glassyiris disabled auto-merge October 11, 2026 14:06

@Zakkaus Zakkaus left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the read/write split works: an unchanged link comes back byte for byte, and checking the edited link with POST /config/validate before the source write is the right guard. A few things before merge:

  1. The edit dialog shows the length limit but still saves. useNodesPage.ts:504 puts nodeFormReason('node', …) in formReason for editNode, so an edited link over 8192 characters shows "too long", while formValid comes from nodeEditState and Save stays enabled. The comment at view.ts says a longer link still fits a source edit, so the length check should apply to node (create) only.
  2. Header names are written as typed. xhttp.ts:126 keeps a name with surrounding spaces, and Object.fromEntries keeps only the last of two rows with the same name, without telling the user. Please trim the names and mark a duplicate name on its row.
  3. Rejections are shown in English. useNodesPage.ts:67 passes the diagnostic's raw message into nodes.linkRejected. diagnosticMessage in src/i18n/backend.ts:148 already turns a ConfigDiagnostic into the translated text; please use it here.
  4. The header comment says more than the code does. xhttp.ts:2 says every other byte survives. That holds for the query, but any field edit writes extra back through JSON.parse and JSON.stringify, so its spacing changes, and integers past 2^53 would lose precision. Please describe that in the comment.
  5. Screenshots. The dialog changes, so please attach light and dark screenshots of the XHTTP section, closed and open.
  6. Checklist and commits. The boxes for understanding the change, the commit format and the gates are unchecked, and the three commits have no body. CONTRIBUTING asks for a short English body on each.
  7. Rebase. Since #541 merged, package.json conflicts on startupActivity. Keep your 342450: main plus this branch comes to about 342,400 by the CI numbers.

@Zakkaus

Zakkaus commented Oct 11, 2026

Copy link
Copy Markdown
Owner

衝突也需要解決

Show a vless or trojan XHTTP link's mode, path, host, headers, padding,
POST pacing and download peer as fields that rewrite only their own part
of the link. Check an edited link with honk's syntax validation before the
source write, so a link honk would skip is refused with its reason, and
refuse links over the 8192 characters node creation accepts.
The startup paths carry the largest language catalogue, and the XHTTP
option labels and help add to all three. CI measured 238517 and 342247
bytes against the previous 238300 and 341850 limits.
honk reads a bare `mux:` line in a node section as the removed standalone
mux setting and rejects it, so the edit check refused a valid link for a
node named mux and renaming a node to mux broke the source. Write and
check that one name quoted; group and DNS references stay unchanged.
Keep pending headers in the node draft and run link preflight inside the shared source-save transaction. Apply only changed XHTTP fields, preserve empty headers, encode apostrophes, and explain missing edit fields.

Quote generated node declaration keys uniformly and lazy-load dialog-only subscription fields without increasing size budgets. Update regressions and user documentation.
Shorten XHTTP help in all three complete catalogues while retaining the defaults, validation, node-ID and download-peer guidance. Keep the existing size budgets: CI's Node 22 gzip output exceeded login by 10 bytes and Activity by 42 bytes.

Verify the production build and size gate with Node 22.23.3, matching CI, and inspect all three languages in the node dialog.
@Zakkaus
Zakkaus merged commit 1d17ece into main Oct 11, 2026
16 checks passed
@Zakkaus
Zakkaus deleted the feat/xhttp-extra branch October 11, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants