remove StatelessResetKey from the Config, it's now on the Transport

This commit is contained in:
Marten Seemann 2023-04-06 19:07:37 +08:00
parent 8189e75be6
commit b79b532b04
7 changed files with 7 additions and 16 deletions

View file

@ -213,7 +213,6 @@ var _ = Describe("Client", func() {
Context("quic.Config", func() {
It("setups with the right values", func() {
srk := &StatelessResetKey{'f', 'o', 'o', 'b', 'a', 'r'}
tokenStore := NewLRUTokenStore(10, 4)
config := &Config{
HandshakeIdleTimeout: 1337 * time.Minute,
@ -221,7 +220,6 @@ var _ = Describe("Client", func() {
MaxIncomingStreams: 1234,
MaxIncomingUniStreams: 4321,
ConnectionIDLength: 13,
StatelessResetKey: srk,
TokenStore: tokenStore,
EnableDatagrams: true,
}
@ -231,7 +229,6 @@ var _ = Describe("Client", func() {
Expect(c.MaxIncomingStreams).To(BeEquivalentTo(1234))
Expect(c.MaxIncomingUniStreams).To(BeEquivalentTo(4321))
Expect(c.ConnectionIDLength).To(Equal(13))
Expect(c.StatelessResetKey).To(Equal(srk))
Expect(c.TokenStore).To(Equal(tokenStore))
Expect(c.EnableDatagrams).To(BeTrue())
})

View file

@ -137,7 +137,6 @@ func populateConfig(config *Config, defaultConnIDLen int) *Config {
MaxIncomingUniStreams: maxIncomingUniStreams,
ConnectionIDLength: conIDLen,
ConnectionIDGenerator: connIDGenerator,
StatelessResetKey: config.StatelessResetKey,
TokenStore: config.TokenStore,
EnableDatagrams: config.EnableDatagrams,
DisablePathMTUDiscovery: config.DisablePathMTUDiscovery,

View file

@ -24,15 +24,15 @@ var _ = Describe("Stateless Resets", func() {
It(fmt.Sprintf("sends and recognizes stateless resets, for %d byte connection IDs", connIDLen), func() {
var statelessResetKey quic.StatelessResetKey
rand.Read(statelessResetKey[:])
serverConfig := getQuicConfig(&quic.Config{StatelessResetKey: &statelessResetKey})
c, err := net.ListenUDP("udp", nil)
Expect(err).ToNot(HaveOccurred())
tr := &quic.Transport{
Conn: c,
Conn: c,
StatelessResetKey: &statelessResetKey,
}
defer tr.Close()
ln, err := tr.Listen(getTLSConfig(), serverConfig)
ln, err := tr.Listen(getTLSConfig(), getQuicConfig(nil))
Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port
@ -90,7 +90,7 @@ var _ = Describe("Stateless Resets", func() {
StatelessResetKey: &statelessResetKey,
}
defer tr2.Close()
ln2, err := tr2.Listen(getTLSConfig(), serverConfig)
ln2, err := tr2.Listen(getTLSConfig(), getQuicConfig(nil))
Expect(err).ToNot(HaveOccurred())
drop.Store(false)

View file

@ -314,9 +314,6 @@ type Config struct {
// If not set, it will default to 100.
// If set to a negative value, it doesn't allow any unidirectional streams.
MaxIncomingUniStreams int64
// The StatelessResetKey is used to generate stateless reset tokens.
// If no key is configured, sending of stateless resets is disabled.
StatelessResetKey *StatelessResetKey
// KeepAlivePeriod defines whether this peer will periodically send a packet to keep the connection alive.
// If set to 0, then no keep alive is sent. Otherwise, the keep alive is sent on that period (or at most
// every half of MaxIdleTimeout, whichever is smaller).

View file

@ -132,7 +132,6 @@ var _ = Describe("Server", func() {
HandshakeIdleTimeout: 1337 * time.Hour,
MaxIdleTimeout: 42 * time.Minute,
KeepAlivePeriod: 5 * time.Second,
StatelessResetKey: &StatelessResetKey{'f', 'o', 'o', 'b', 'a', 'r'},
RequireAddressValidation: requireAddrVal,
}
ln, err := Listen(conn, tlsConf, &config)
@ -144,7 +143,6 @@ var _ = Describe("Server", func() {
Expect(server.config.MaxIdleTimeout).To(Equal(42 * time.Minute))
Expect(reflect.ValueOf(server.config.RequireAddressValidation)).To(Equal(reflect.ValueOf(requireAddrVal)))
Expect(server.config.KeepAlivePeriod).To(Equal(5 * time.Second))
Expect(server.config.StatelessResetKey).To(Equal(&StatelessResetKey{'f', 'o', 'o', 'b', 'a', 'r'}))
// stop the listener
Expect(ln.Close()).To(Succeed())
})

View file

@ -207,7 +207,6 @@ func (t *Transport) init(conf *Config) error {
return
}
t.StatelessResetKey = conf.StatelessResetKey
t.Tracer = conf.Tracer
t.ConnectionIDLength = conf.ConnectionIDLength
t.ConnectionIDGenerator = conf.ConnectionIDGenerator

View file

@ -251,9 +251,10 @@ var _ = Describe("Transport", func() {
packetChan := make(chan packetToRead)
conn := newMockPacketConn(packetChan)
tr := Transport{
Conn: conn,
Conn: conn,
StatelessResetKey: &StatelessResetKey{1, 2, 3, 4},
}
tr.init(&Config{ConnectionIDLength: connID.Len(), StatelessResetKey: &StatelessResetKey{1, 2, 3, 4}})
tr.init(&Config{ConnectionIDLength: connID.Len()})
defer tr.Close()
phm := NewMockPacketHandlerManager(mockCtrl)
tr.init(&Config{})