fix(olcrtc): validate profile inputs - #153
Conversation
📝 WalkthroughWalkthroughOLCRTC validation is centralized across URI parsing, serialization, CLI argument generation, and profile saving. Transport compatibility, VP8 values, encryption keys, DNS endpoints, payload syntax, client IDs, and carrier host extraction now have stricter handling with expanded tests. ChangesOLCRTC validation and codec
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/src/main/java/io/nekohasekai/sagernet/fmt/olcrtc/OlcrtcFmt.kt`:
- Around line 146-148: Update the cid handling in the parser’s `"cid",
"client-id", "clientid"` branch to apply the same URI delimiter validation used
for other parsed values, rejecting payloads containing reserved delimiters such
as `=`. Ensure invalid cid input is rejected during import while valid client
IDs continue assigning to clientId and remain serializable through toUri().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 45d00970-9cf0-443b-9885-4eba040f83ea
📒 Files selected for processing (3)
app/src/main/java/io/nekohasekai/sagernet/fmt/olcrtc/OlcrtcFmt.ktapp/src/main/java/io/nekohasekai/sagernet/ui/profile/OlcrtcSettingsActivity.ktapp/src/test/java/io/nekohasekai/sagernet/fmt/OlcrtcFmtTest.kt
|
Applied the current review fixes in
Namespace validation is running on the updated branch. |
| authority.startsWith('[') -> { | ||
| val closingBracket = authority.indexOf(']') |
There was a problem hiding this comment.
When a Jitsi room uses a bracketed IPv6 signaling host, this branch returns the bare literal, such as 2001:db8::1. The DNS direct-force caller only skips values that isIpAddress() recognizes, and that check handles IPv4-style octets, so this IPv6 literal is treated as a domain and emitted as full:2001:db8::1. That can leave the config with an invalid or non-matching DNS rule instead of cleanly skipping IP signaling targets. The IPv6 host path should either return no domain here or be filtered by an IP check that recognizes IPv6 before adding full:.
There was a problem hiding this comment.
No change is needed here. ConfigBuilder filters this value through String.isIpAddress(), which explicitly checks both NGUtil.isIpv4Address() and NGUtil.isIpv6Address(). The bare compressed IPv6 literal is recognized and skipped, so it is not emitted as a full: domain rule.
|
Superseded by #157, which carries this validation with the matching runtime pin and recovery changes at the tested combined SHA. |
Summary
Validation
Greptile Summary
This PR tightens olcRTC profile handling and validation. The main changes are:
Confidence Score: 4/5
This is close, but the IPv6 host path should be fixed before merging.
app/src/main/java/io/nekohasekai/sagernet/fmt/olcrtc/OlcrtcFmt.kt
Important Files Changed
Reviews (2): Last reviewed commit: "fix(olcrtc): address profile review feed..." | Re-trigger Greptile