Repository navigation
feat: surface the mitm configuration chapter in the editors - #49
TiaraBasori wants to merge 2 commits into
Conversation
Registers the new top-level mitm: block (companion to the kernel's component/mitm) across the configuration surface: outline section with On/Off and policy counts, field-copy strings (en/zh-Hans/zh-Hant), a chapters layout (Basics / Scope / Rewrite Policies), domain and CIDR list validation paths, the governing-switch audit, upstream default pins, and the Mac/iOS/tvOS switch coverage for the new section. Field-level definitions ride the kernel's syntax catalog (reflected from RawConfig), so no local field table is needed. The CA install flow needs the MITMState/ExportMITMCa exports from a released SDK and lands as a follow-up once the kernel PR ships.
Review found the eight rewrite-child copy keys using the '.*' wildcard form while the kernel's reflected catalog emits objectList children as 'mitm.rewrite[].url-pattern' etc., leaving all eight records unreachable (editors showed raw YAML key names). Rekeyed to the '[]' form. Also: the iOS outline's MITM row now shows On/Off like the Mac card and the sniffer row (mitmEnabled mirrors snifferEnabled), the url-pattern summary states the actual suffix-match semantics (host and subdomains), value-prefix copy reflects the new prepend-to-client-value behavior, and the mitm chapter gains the standard 'More Settings' catchall so future kernel keys surface under a curated header.
|
Pushed
|
TiaraBasori
left a comment
There was a problem hiding this comment.
Hermes Agent Review (round 2 — paired with core PR #8)
Cross-checked against the kernel PR (ProjectClash/Clash#8, same feature). Client-side surface looks solid overall: chapter wiring is complete and consistent across iPhone/Mac editors (outline section, route, governing-switch audit list, trie/IP validation paths, pinned defaults, On/Off parity in both editors), and the zh-Hans/zh-Hant/en copy is accurate against the kernel's actual semantics (verified: +.example.com suffix semantics, first-match policies, bare-host redirect keeping path+query, value-prefix prepending, reject 4xx, default ports 443/80).
Findings (all minor — nothing blocking found):
-
⚠️ No mention of the CA install step as a dependency. The copy says "启用前请先在应用内安装并信任 CA" but nothing in the editor links to the CA surface (MITMState/ExportMITMCa added in the core PR's bind layer). A user can flipmitm.enableand every gated site breaks with TLS errors until they find the CA export elsewhere. Consider a footer link or warning state when enable=true and no profile is installed (the core exposesMITMStatefor exactly this). -
⚠️ store-dirfree-text path is a footgun on iOS. The kernel persists the CA under whatever path the client passes; the editor exposes it as a raw string field. On iOS a user-entered path either points outside the app-group container (write fails → MITM silently disabled, executor logsinitial mitm failed) or inside it (fine but obscure). Better to hide it behind an expert toggle or manage it app-side rather than exposing it as an editable field. -
💡 Outline count for
.mitmcountsrewriteentries (ConfigurationOutline.swift:policies = field(mitm, "rewrite")) — consistent with sniffer'ssniffcount, fine; buthostsbeing empty withenable: trueis the misconfiguration the kernel warns about at load ("hosts are configured but no rewrite policies" is the other one). Neither is surfaced client-side; a small validation hint would help. -
💡
layouts-chapters.json"More Settings" catch-all (*) now picks up nothing unexpected — checked against the kernel's RawMITM field set (enable/store-dir/hosts/skip-domain/skip-dst-address/https-ports/http-ports/rewrite); all six listed keys in the chapters match real fields, no typos. -
💡
mitmEnabled(in:)duplicates the sniffer on/off extraction logic; a shared helper would avoid drift, but consistent with existing style.
Verified locally that the three Swift packages touched compile-clean is not possible in this environment (no Xcode toolchain); the diff is confined to additive enum cases + JSON resources, and every switch over ConfigurationOutlineSection in the diff was extended (checked: EditorViews, OnePage route, Mac inspector, Mac outline card, Mac page objects, ConfigurationOutline sections/defaults — no non-exhaustive switch left behind).
Summary
mitm:block across the configuration editing surface: outline section with On/Off state and rewrite-policy counts, trilingual field copy, a chapters layout, list-validation paths, and the governing-switch audit.Motivation
Companion to ProjectClash/Clash#8, which adds the kernel-side
component/mitmengine behind the samemitm:block. Without this PR the editors treatmitmas an unknown key and the configuration center cannot show or edit it.Changes
ConfigurationOutlineSection.mitm(ordered after sniffer), outline row countingmitm.rewritewith theenablestate,mitm.skip-domainin the trie-domain validation paths,mitm.skip-dst-addressin the IP-matcher paths,mitm.enablein the audited governing switches.FieldCopy/a-mitm.json: titles/summaries for everymitm.*path (en, 简体, 繁體), including therewrite.*object-list andheaders.*sub-entries;layouts-chapters.json: a MITM chapter with Basics / Scope / Rewrite Policies;mitm.enableand the sixmitmlist paths pinned in the upstream-default tables (preconditionFailureguards require the pins).ConfigurationOutlineSectionextended for the new case (route, copy, value, inspector destinations, search-index page set, On/Off rendering).Field-level definitions are intentionally not duplicated here: the editors' field catalog is reflected from
RawConfigby the kernel'sSyntaxCatalogForIOS, somitm.*fields appear automatically once the kernel PR's SDK ships.Test Plan
ConfigurationOutlineSection: no switch on the enum lacks.mitmor adefaultarm.mitmchapter with the pinned keys.mitmlist path the editors can touch (nopreconditionFailureon first open).Notes for Reviewers
MITMState/ExportMITMCafrom the core) needs the new exports in a released SDK; it is deliberately left out here so this PR compiles against the currentDependencies.lock.json. It lands as a follow-up once the kernel PR merges and a new SDK is pinned.