Skip to content

Commit 56f3077

Browse files
authored
fix(vpn): set NoDrop on reject rule action (#627)
* fix(vpn): set NoDrop on reject rule action Also add comment-guidance line to AGENTS.md on keeping invariant comments minimal. * fix(vpn): scope NoDrop to the IPv6 reject rule NoDrop is only needed on the ::/0 reject so Happy Eyeballs fails over to IPv4 instead of dropping. Move it off the general reject rule and assert it in TestRejectIPv6Rule.
1 parent 89008b5 commit 56f3077

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Prefer clearer names and smaller functions over explanatory comments.
88
- Delete or shorten verbose comments in code you touch.
9+
- A comment that documents a real invariant, race, or rationale still fails if it includes more detail than needed to preserve that contract.
910
- Do not narrate code, repeat the identifier, list visible branches, mention tickets/people, or praise the implementation.
1011
- Documentation should only document the declaration's own contract: side effects, blocking/zero-value behavior, errors, ownership, cancellation, concurrency, or surprising pre/postconditions.
1112
- Document the caller-relevant semantics of a sentinel error, enum, status, or constant — retryability, permanence, lifecycle — as the value's own contract, phrased as what it means rather than advice: prefer "retryable only after …" over "callers should …". The consumer behavior to avoid is a separate component's policy, not the meaning of a value callers inspect.

vpn/boxoptions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,9 @@ func highMemoryRejectRule() O.Rule {
633633
// RST) makes Happy Eyeballs fail over at once; "drop" would blackhole and stall.
634634
// Must be appended after the direct-routing rules so intentionally-direct v6 is kept.
635635
func rejectIPv6Rule() O.Rule {
636-
return rejectRule(O.RawDefaultRule{IPCIDR: []string{"::/0"}})
636+
rule := rejectRule(O.RawDefaultRule{IPCIDR: []string{"::/0"}})
637+
rule.DefaultOptions.RuleAction.RejectOptions.NoDrop = true
638+
return rule
637639
}
638640

639641
func newDNSServerOptions(typ, tag, server, domainResolver string) O.DNSServerOptions {

vpn/boxoptions_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ func TestRejectIPv6Rule(t *testing.T) {
526526
assert.Equal(t, []string{"::/0"}, []string(r.DefaultOptions.RawDefaultRule.IPCIDR))
527527
assert.NotEqual(t, C.RuleActionRejectMethodDrop, r.DefaultOptions.RuleAction.RejectOptions.Method,
528528
"must not use the drop method — a silent blackhole stalls instead of failing over to IPv4")
529+
assert.True(t, r.DefaultOptions.RuleAction.RejectOptions.NoDrop,
530+
"NoDrop must be set so the reject returns unreachable instead of dropping")
529531
}
530532

531533
func TestTunHasIPv6(t *testing.T) {

0 commit comments

Comments
 (0)