Skip to content

Commit 945651b

Browse files
committed
Invert boolean options for simplicity
1 parent 24de087 commit 945651b

File tree

4 files changed

+14
-33
lines changed

4 files changed

+14
-33
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ Samizdat is implemented as a standalone library ([`samizdat`](https://github.com
4444
"short_id": "0123456789abcdef",
4545
"server_name": "ok.ru",
4646
"fingerprint": "chrome",
47-
"padding": true,
48-
"jitter": true,
49-
"tcp_fragmentation": true,
50-
"record_fragmentation": true
47+
"disable_padding": false,
48+
"disable_jitter": false,
49+
"disable_tcp_fragmentation": false,
50+
"disable_record_fragmentation": false
5151
}
5252
]
5353
}

option/samizdat.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ type SamizdatOutboundOptions struct {
1515
ServerName string `json:"server_name,omitempty"` // cover site SNI (e.g. "ok.ru")
1616
Fingerprint string `json:"fingerprint,omitempty"` // "chrome" (default), "firefox", "safari"
1717

18-
// Traffic shaping (pointer types so unset is distinguishable from explicitly false)
19-
Padding *bool `json:"padding,omitempty"` // enable H2 DATA frame padding (default: true)
20-
Jitter *bool `json:"jitter,omitempty"` // enable timing jitter (default: true)
18+
// Traffic shaping (enabled by default; set to true to disable)
19+
DisablePadding bool `json:"disable_padding,omitempty"` // disable H2 DATA frame padding
20+
DisableJitter bool `json:"disable_jitter,omitempty"` // disable timing jitter
2121
MaxJitterMs int `json:"max_jitter_ms,omitempty"` // max jitter in ms (default: 30)
2222
PaddingProfile string `json:"padding_profile,omitempty"` // "chrome", "firefox" (default: "chrome")
2323

24-
// TCP fragmentation (Geneva-inspired)
25-
TCPFragmentation *bool `json:"tcp_fragmentation,omitempty"` // fragment ClientHello (default: true)
26-
RecordFragmentation *bool `json:"record_fragmentation,omitempty"` // fragment TLS records (default: true)
24+
// TCP fragmentation (Geneva-inspired; enabled by default; set to true to disable)
25+
DisableTCPFragmentation bool `json:"disable_tcp_fragmentation,omitempty"` // disable ClientHello fragmentation
26+
DisableRecordFragmentation bool `json:"disable_record_fragmentation,omitempty"` // disable TLS record fragmentation
2727

2828
// Connection management
2929
MaxStreamsPerConn int `json:"max_streams_per_conn,omitempty"` // max H2 streams per TCP conn (default: 100)

protocol/samizdat/outbound.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ func NewOutbound(
103103
PublicKey: pubKey,
104104
ShortID: shortID,
105105
Fingerprint: options.Fingerprint,
106-
Padding: boolDefault(options.Padding, true),
107-
Jitter: boolDefault(options.Jitter, true),
106+
Padding: !options.DisablePadding,
107+
Jitter: !options.DisableJitter,
108108
MaxJitterMs: options.MaxJitterMs,
109109
PaddingProfile: options.PaddingProfile,
110-
TCPFragmentation: boolDefault(options.TCPFragmentation, true),
111-
RecordFragmentation: boolDefault(options.RecordFragmentation, true),
110+
TCPFragmentation: !options.DisableTCPFragmentation,
111+
RecordFragmentation: !options.DisableRecordFragmentation,
112112
MaxStreamsPerConn: options.MaxStreamsPerConn,
113113
IdleTimeout: idleTimeout,
114114
ConnectTimeout: connectTimeout,
@@ -181,10 +181,3 @@ func (o *Outbound) Close() error {
181181
return nil
182182
}
183183

184-
// boolDefault returns the value pointed to by p, or defaultVal if p is nil.
185-
func boolDefault(p *bool, defaultVal bool) bool {
186-
if p != nil {
187-
return *p
188-
}
189-
return defaultVal
190-
}

protocol/samizdat/samizdat_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,6 @@ func validInboundOptions(t *testing.T) option.SamizdatInboundOptions {
8585
}
8686
}
8787

88-
// --- boolDefault tests ---
89-
90-
func TestBoolDefault(t *testing.T) {
91-
trueVal := true
92-
falseVal := false
93-
94-
assert.True(t, boolDefault(&trueVal, false), "pointer to true should return true")
95-
assert.False(t, boolDefault(&falseVal, true), "pointer to false should return false")
96-
assert.True(t, boolDefault(nil, true), "nil should return default true")
97-
assert.False(t, boolDefault(nil, false), "nil should return default false")
98-
}
99-
10088
// --- NewInbound validation tests ---
10189

10290
func TestNewInbound_InvalidPrivateKey(t *testing.T) {

0 commit comments

Comments
 (0)