Add advanced Hysteria2 client options#35
Conversation
📝 WalkthroughWalkthroughEight advanced HY2 QUIC tuning parameters (stream/connection receive windows, max idle timeout, keep-alive period, hop interval min/max) are added to ChangesHY2 Advanced QUIC Options
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
5d1c476 to
ff91fdc
Compare
Summary
Validation
git diff --check./gradlew :app:compileOssDebugKotlin./gradlew :app:dexBuilderOssDebug+ clean generated AppleDouble files +./gradlew :app:assembleOssDebugNote: builds on this external volume can generate macOS AppleDouble
._*files in intermediate outputs; I usedcleanfork --path .between build phases to keep AAPT/D8 inputs clean.Greptile Summary
This PR extends the Hysteria2 profile model with eight new advanced QUIC fields (stream/connection receive windows, idle timeout, keepalive period, path MTU discovery toggle, and random hop-interval min/max), wires them through the UI, DataStore, serialization (version 9), and URI import/export, and routes HY2 profiles that use any of those fields through the bundled Hysteria2 sidecar binary instead of the sing-box core.
HysteriaBeangains 8 newIntegerfields with a versioned deserialize block (v9);DataStoreusesstringToIntIfExistsso null correctly means "use Hysteria default" rather than an explicit zero.hasAdvancedHysteria2Options()returns true when any advanced field is set (hop-interval check is correctly gated onisMultiPort), flippingcanUseSingBox()to false and directing those profiles tobuildHysteria2SidecarConfig, which emits the appropriate Hysteria2 JSON with aquicsection and, for multi-port servers, atransport/udpsection with the hop intervals.parseDurationSecondsnow handlesms,s,m, andhsuffixes (improving on the previous\"s\"-only stripping);queryInt/queryBool/querySecondshelpers accept camelCase, snake_case, and kebab-case variants of each parameter name for broad interoperability.Confidence Score: 5/5
Safe to merge; the new sidecar routing correctly falls back to the original sing-box path for all unmodified HY2 profiles.
The serialization version bump (8→9) is correct and backward-compatible, the sidecar routing predicate guards hop-interval checks on isMultiPort as expected, and the parseDurationSeconds helper handles all common duration suffixes safely. The only nit is that hopInterval can be emitted for single-port URIs, which is harmless but inconsistent with how the sidecar config builder treats that field.
HysteriaFmt.kt — the toUri() hop-interval emission path is the only place worth a second look.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[HysteriaBean profile] --> B{protocolVersion == 2?} B -- No --> C[HY1 path: canUseSingBox returns false for non-UDP] B -- Yes --> D{hasAdvancedHysteria2Options?} D -- No --> E[canUseSingBox = true / buildSingBoxOutboundHysteriaBean] D -- Yes --> F[canUseSingBox = false / buildHysteria2SidecarConfig] F --> G{isMultiPort?} G -- Yes --> H[Add transport section with hop intervals] G -- No --> I[No transport section] H --> J[Add quic section: windows / timeout / keepalive / MTU] I --> J J --> K[hysteria2-plugin sidecar process] E --> L[sing-box hysteria2 outbound]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[HysteriaBean profile] --> B{protocolVersion == 2?} B -- No --> C[HY1 path: canUseSingBox returns false for non-UDP] B -- Yes --> D{hasAdvancedHysteria2Options?} D -- No --> E[canUseSingBox = true / buildSingBoxOutboundHysteriaBean] D -- Yes --> F[canUseSingBox = false / buildHysteria2SidecarConfig] F --> G{isMultiPort?} G -- Yes --> H[Add transport section with hop intervals] G -- No --> I[No transport section] H --> J[Add quic section: windows / timeout / keepalive / MTU] I --> J J --> K[hysteria2-plugin sidecar process] E --> L[sing-box hysteria2 outbound]Reviews (2): Last reviewed commit: "Add advanced Hysteria2 client options" | Re-trigger Greptile