fix(tuic): bound the timeout settings at a day

max_idle_time and authentication_timeout are second counts multiplied
into a Duration with no bound, so a stored value past the int64 range
wrapped negative and the QUIC listener panicked on the first
ClientHello, taking the panel down at every start until the row was
fixed. Saves now refuse more than a day, and a stored row past it fails
its own listener start instead.
This commit is contained in:
MHSanaei
2026-10-31 14:53:20 +01:00
parent 425a2bbf08
commit 5cf2ab4f69
4 changed files with 43 additions and 0 deletions
+16
View File
@@ -127,3 +127,19 @@ func TestEnsureStartupFailureHonorsInboundLogThreshold(t *testing.T) {
})
}
}
// Seconds turn into a Duration by multiplication; a pushed value past the int64 range
// wrapped negative and the QUIC listener panicked on the first ClientHello, every start.
func TestNewServerRefusesTimeoutsPastADay(t *testing.T) {
cert, key := generateTestCert(t)
for name, inst := range map[string]Instance{
"max_idle_time": {MaxIdleTime: 1 << 40},
"authentication_timeout": {AuthenticationTimeout: MaxTimeoutSeconds + 1},
} {
inst.Listen, inst.Certificate, inst.PrivateKey = "127.0.0.1", string(cert), string(key)
if s, err := NewServer(inst, &SocksRelay{Addr: "127.0.0.1:1"}); err == nil {
_ = s.Close()
t.Errorf("%s past a day was accepted", name)
}
}
}