mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
rename original_connection_id to original_destination_connection_id TP
This commit is contained in:
parent
fe85b52eed
commit
7e62a2fecc
7 changed files with 131 additions and 131 deletions
|
@ -33,13 +33,13 @@ var _ = Describe("Transport Parameters", func() {
|
|||
MaxBidiStreamNum: 1337,
|
||||
MaxUniStreamNum: 7331,
|
||||
MaxIdleTimeout: 42 * time.Second,
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
AckDelayExponent: 14,
|
||||
MaxAckDelay: 37 * time.Millisecond,
|
||||
StatelessResetToken: &[16]byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00},
|
||||
ActiveConnectionIDLimit: 123,
|
||||
}
|
||||
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 1234, InitialMaxStreamDataBidiRemote: 2345, InitialMaxStreamDataUni: 3456, InitialMaxData: 4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37ms, ActiveConnectionIDLimit: 123, StatelessResetToken: 0x112233445566778899aabbccddeeff00}"))
|
||||
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalDestinationConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 1234, InitialMaxStreamDataBidiRemote: 2345, InitialMaxStreamDataUni: 3456, InitialMaxData: 4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37ms, ActiveConnectionIDLimit: 123, StatelessResetToken: 0x112233445566778899aabbccddeeff00}"))
|
||||
})
|
||||
|
||||
It("has a string representation, if there's no stateless reset token", func() {
|
||||
|
@ -51,12 +51,12 @@ var _ = Describe("Transport Parameters", func() {
|
|||
MaxBidiStreamNum: 1337,
|
||||
MaxUniStreamNum: 7331,
|
||||
MaxIdleTimeout: 42 * time.Second,
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
AckDelayExponent: 14,
|
||||
MaxAckDelay: 37 * time.Second,
|
||||
ActiveConnectionIDLimit: 89,
|
||||
}
|
||||
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 1234, InitialMaxStreamDataBidiRemote: 2345, InitialMaxStreamDataUni: 3456, InitialMaxData: 4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37s, ActiveConnectionIDLimit: 89}"))
|
||||
Expect(p.String()).To(Equal("&wire.TransportParameters{OriginalDestinationConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 1234, InitialMaxStreamDataBidiRemote: 2345, InitialMaxStreamDataUni: 3456, InitialMaxData: 4567, MaxBidiStreamNum: 1337, MaxUniStreamNum: 7331, MaxIdleTimeout: 42s, AckDelayExponent: 14, MaxAckDelay: 37s, ActiveConnectionIDLimit: 89}"))
|
||||
})
|
||||
|
||||
It("marshals and unmarshals", func() {
|
||||
|
@ -72,7 +72,7 @@ var _ = Describe("Transport Parameters", func() {
|
|||
MaxUniStreamNum: protocol.StreamNum(getRandomValue()),
|
||||
DisableActiveMigration: true,
|
||||
StatelessResetToken: &token,
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
AckDelayExponent: 13,
|
||||
MaxAckDelay: 42 * time.Millisecond,
|
||||
ActiveConnectionIDLimit: getRandomValue(),
|
||||
|
@ -90,7 +90,7 @@ var _ = Describe("Transport Parameters", func() {
|
|||
Expect(p.MaxIdleTimeout).To(Equal(params.MaxIdleTimeout))
|
||||
Expect(p.DisableActiveMigration).To(Equal(params.DisableActiveMigration))
|
||||
Expect(p.StatelessResetToken).To(Equal(params.StatelessResetToken))
|
||||
Expect(p.OriginalConnectionID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}))
|
||||
Expect(p.OriginalDestinationConnectionID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}))
|
||||
Expect(p.AckDelayExponent).To(Equal(uint8(13)))
|
||||
Expect(p.MaxAckDelay).To(Equal(42 * time.Millisecond))
|
||||
Expect(p.ActiveConnectionIDLimit).To(Equal(params.ActiveConnectionIDLimit))
|
||||
|
@ -253,10 +253,10 @@ var _ = Describe("Transport Parameters", func() {
|
|||
|
||||
It("errors if the client sent a stateless_reset_token", func() {
|
||||
params := &TransportParameters{
|
||||
OriginalConnectionID: protocol.ConnectionID{0xca, 0xfe},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xca, 0xfe},
|
||||
}
|
||||
data := params.Marshal()
|
||||
Expect((&TransportParameters{}).Unmarshal(data, protocol.PerspectiveClient)).To(MatchError("TRANSPORT_PARAMETER_ERROR: client sent an original_connection_id"))
|
||||
Expect((&TransportParameters{}).Unmarshal(data, protocol.PerspectiveClient)).To(MatchError("TRANSPORT_PARAMETER_ERROR: client sent an original_destination_connection_id"))
|
||||
})
|
||||
|
||||
Context("preferred address", func() {
|
||||
|
|
|
@ -25,7 +25,7 @@ func init() {
|
|||
type transportParameterID uint64
|
||||
|
||||
const (
|
||||
originalConnectionIDParameterID transportParameterID = 0x0
|
||||
originalDestinationConnectionIDParameterID transportParameterID = 0x0
|
||||
maxIdleTimeoutParameterID transportParameterID = 0x1
|
||||
statelessResetTokenParameterID transportParameterID = 0x2
|
||||
maxUDPPayloadSizeParameterID transportParameterID = 0x3
|
||||
|
@ -74,7 +74,7 @@ type TransportParameters struct {
|
|||
PreferredAddress *PreferredAddress
|
||||
|
||||
StatelessResetToken *[16]byte
|
||||
OriginalConnectionID protocol.ConnectionID
|
||||
OriginalDestinationConnectionID protocol.ConnectionID
|
||||
ActiveConnectionIDLimit uint64
|
||||
}
|
||||
|
||||
|
@ -155,11 +155,11 @@ func (p *TransportParameters) unmarshal(data []byte, sentBy protocol.Perspective
|
|||
var token [16]byte
|
||||
r.Read(token[:])
|
||||
p.StatelessResetToken = &token
|
||||
case originalConnectionIDParameterID:
|
||||
case originalDestinationConnectionIDParameterID:
|
||||
if sentBy == protocol.PerspectiveClient {
|
||||
return errors.New("client sent an original_connection_id")
|
||||
return errors.New("client sent an original_destination_connection_id")
|
||||
}
|
||||
p.OriginalConnectionID, _ = protocol.ReadConnectionID(r, int(paramLen))
|
||||
p.OriginalDestinationConnectionID, _ = protocol.ReadConnectionID(r, int(paramLen))
|
||||
default:
|
||||
r.Seek(int64(paramLen), io.SeekCurrent)
|
||||
}
|
||||
|
@ -347,10 +347,10 @@ func (p *TransportParameters) Marshal() []byte {
|
|||
b.Write(p.PreferredAddress.ConnectionID.Bytes())
|
||||
b.Write(p.PreferredAddress.StatelessResetToken[:])
|
||||
}
|
||||
if p.OriginalConnectionID.Len() > 0 {
|
||||
utils.WriteVarInt(b, uint64(originalConnectionIDParameterID))
|
||||
utils.WriteVarInt(b, uint64(p.OriginalConnectionID.Len()))
|
||||
b.Write(p.OriginalConnectionID.Bytes())
|
||||
if p.OriginalDestinationConnectionID.Len() > 0 {
|
||||
utils.WriteVarInt(b, uint64(originalDestinationConnectionIDParameterID))
|
||||
utils.WriteVarInt(b, uint64(p.OriginalDestinationConnectionID.Len()))
|
||||
b.Write(p.OriginalDestinationConnectionID.Bytes())
|
||||
}
|
||||
|
||||
// active_connection_id_limit
|
||||
|
@ -416,8 +416,8 @@ func (p *TransportParameters) ValidFor0RTT(tp *TransportParameters) bool {
|
|||
|
||||
// String returns a string representation, intended for logging.
|
||||
func (p *TransportParameters) String() string {
|
||||
logString := "&wire.TransportParameters{OriginalConnectionID: %s, InitialMaxStreamDataBidiLocal: %d, InitialMaxStreamDataBidiRemote: %d, InitialMaxStreamDataUni: %d, InitialMaxData: %d, MaxBidiStreamNum: %d, MaxUniStreamNum: %d, MaxIdleTimeout: %s, AckDelayExponent: %d, MaxAckDelay: %s, ActiveConnectionIDLimit: %d"
|
||||
logParams := []interface{}{p.OriginalConnectionID, p.InitialMaxStreamDataBidiLocal, p.InitialMaxStreamDataBidiRemote, p.InitialMaxStreamDataUni, p.InitialMaxData, p.MaxBidiStreamNum, p.MaxUniStreamNum, p.MaxIdleTimeout, p.AckDelayExponent, p.MaxAckDelay, p.ActiveConnectionIDLimit}
|
||||
logString := "&wire.TransportParameters{OriginalDestinationConnectionID: %s, InitialMaxStreamDataBidiLocal: %d, InitialMaxStreamDataBidiRemote: %d, InitialMaxStreamDataUni: %d, InitialMaxData: %d, MaxBidiStreamNum: %d, MaxUniStreamNum: %d, MaxIdleTimeout: %s, AckDelayExponent: %d, MaxAckDelay: %s, ActiveConnectionIDLimit: %d"
|
||||
logParams := []interface{}{p.OriginalDestinationConnectionID, p.InitialMaxStreamDataBidiLocal, p.InitialMaxStreamDataBidiRemote, p.InitialMaxStreamDataUni, p.InitialMaxData, p.MaxBidiStreamNum, p.MaxUniStreamNum, p.MaxIdleTimeout, p.AckDelayExponent, p.MaxAckDelay, p.ActiveConnectionIDLimit}
|
||||
if p.StatelessResetToken != nil { // the client never sends a stateless reset token
|
||||
logString += ", StatelessResetToken: %#x"
|
||||
logParams = append(logParams, *p.StatelessResetToken)
|
||||
|
|
|
@ -326,7 +326,7 @@ func (e eventKeyRetired) MarshalJSONObject(enc *gojay.Encoder) {
|
|||
type eventTransportParameters struct {
|
||||
Owner owner
|
||||
|
||||
OriginalConnectionID protocol.ConnectionID
|
||||
OriginalDestinationConnectionID protocol.ConnectionID
|
||||
StatelessResetToken *[16]byte
|
||||
DisableActiveMigration bool
|
||||
MaxIdleTimeout time.Duration
|
||||
|
@ -351,8 +351,8 @@ func (e eventTransportParameters) IsNil() bool { return false }
|
|||
|
||||
func (e eventTransportParameters) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("owner", e.Owner.String())
|
||||
if e.OriginalConnectionID != nil {
|
||||
enc.StringKey("original_connection_id", connectionID(e.OriginalConnectionID).String())
|
||||
if e.OriginalDestinationConnectionID != nil {
|
||||
enc.StringKey("original_destination_connection_id", connectionID(e.OriginalDestinationConnectionID).String())
|
||||
}
|
||||
if e.StatelessResetToken != nil {
|
||||
enc.StringKey("stateless_reset_token", fmt.Sprintf("%x", e.StatelessResetToken[:]))
|
||||
|
|
|
@ -173,7 +173,7 @@ func (t *tracer) recordTransportParameters(owner owner, tp *wire.TransportParame
|
|||
t.mutex.Lock()
|
||||
t.recordEvent(time.Now(), &eventTransportParameters{
|
||||
Owner: owner,
|
||||
OriginalConnectionID: tp.OriginalConnectionID,
|
||||
OriginalDestinationConnectionID: tp.OriginalDestinationConnectionID,
|
||||
StatelessResetToken: tp.StatelessResetToken,
|
||||
DisableActiveMigration: tp.DisableActiveMigration,
|
||||
MaxIdleTimeout: tp.MaxIdleTimeout,
|
||||
|
|
|
@ -183,7 +183,7 @@ var _ = Describe("Tracer", func() {
|
|||
MaxUDPPayloadSize: 1234,
|
||||
MaxIdleTimeout: 321 * time.Millisecond,
|
||||
StatelessResetToken: &[16]byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00},
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xad, 0xc0, 0xde},
|
||||
ActiveConnectionIDLimit: 7,
|
||||
})
|
||||
entry := exportAndParseSingle()
|
||||
|
@ -192,7 +192,7 @@ var _ = Describe("Tracer", func() {
|
|||
Expect(entry.Name).To(Equal("parameters_set"))
|
||||
ev := entry.Event
|
||||
Expect(ev).To(HaveKeyWithValue("owner", "local"))
|
||||
Expect(ev).To(HaveKeyWithValue("original_connection_id", "deadc0de"))
|
||||
Expect(ev).To(HaveKeyWithValue("original_destination_connection_id", "deadc0de"))
|
||||
Expect(ev).To(HaveKeyWithValue("stateless_reset_token", "112233445566778899aabbccddeeff00"))
|
||||
Expect(ev).To(HaveKeyWithValue("max_idle_timeout", float64(321)))
|
||||
Expect(ev).To(HaveKeyWithValue("max_udp_payload_size", float64(1234)))
|
||||
|
|
|
@ -272,7 +272,7 @@ var newSession = func(
|
|||
AckDelayExponent: protocol.AckDelayExponent,
|
||||
DisableActiveMigration: true,
|
||||
StatelessResetToken: &statelessResetToken,
|
||||
OriginalConnectionID: origDestConnID,
|
||||
OriginalDestinationConnectionID: origDestConnID,
|
||||
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
|
||||
}
|
||||
if s.qlogger != nil {
|
||||
|
@ -1275,8 +1275,8 @@ func (s *session) processTransportParameters(params *wire.TransportParameters) {
|
|||
}
|
||||
|
||||
// check the Retry token
|
||||
if s.perspective == protocol.PerspectiveClient && !params.OriginalConnectionID.Equal(s.origDestConnID) {
|
||||
s.closeLocal(qerr.NewError(qerr.TransportParameterError, fmt.Sprintf("expected original_connection_id to equal %s, is %s", s.origDestConnID, params.OriginalConnectionID)))
|
||||
if s.perspective == protocol.PerspectiveClient && !params.OriginalDestinationConnectionID.Equal(s.origDestConnID) {
|
||||
s.closeLocal(qerr.NewError(qerr.TransportParameterError, fmt.Sprintf("expected original_destination_connection_id to equal %s, is %s", s.origDestConnID, params.OriginalDestinationConnectionID)))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -2259,27 +2259,27 @@ var _ = Describe("Client Session", func() {
|
|||
Expect(sess.idleTimeout).To(Equal(18 * time.Second))
|
||||
})
|
||||
|
||||
It("errors if the TransportParameters contain an original_connection_id, although no Retry was performed", func() {
|
||||
It("errors if the TransportParameters contain an original_destination_connection_id, although no Retry was performed", func() {
|
||||
params := &wire.TransportParameters{
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||
}
|
||||
expectClose()
|
||||
qlogger.EXPECT().ReceivedTransportParameters(params)
|
||||
sess.processTransportParameters(params)
|
||||
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_connection_id to equal (empty), is 0xdecafbad")))
|
||||
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_destination_connection_id to equal (empty), is 0xdecafbad")))
|
||||
})
|
||||
|
||||
It("errors if the TransportParameters contain a wrong original_connection_id", func() {
|
||||
It("errors if the TransportParameters contain a wrong original_destination_connection_id", func() {
|
||||
sess.origDestConnID = protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}
|
||||
params := &wire.TransportParameters{
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||
OriginalDestinationConnectionID: protocol.ConnectionID{0xde, 0xca, 0xfb, 0xad},
|
||||
StatelessResetToken: &[16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||
}
|
||||
expectClose()
|
||||
qlogger.EXPECT().ReceivedTransportParameters(params)
|
||||
sess.processTransportParameters(params)
|
||||
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_connection_id to equal 0xdeadbeef, is 0xdecafbad")))
|
||||
Eventually(errChan).Should(Receive(MatchError("TRANSPORT_PARAMETER_ERROR: expected original_destination_connection_id to equal 0xdeadbeef, is 0xdecafbad")))
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue