forked from quic-go/quic-go
add GetIdleConnectionStateLifetime to connection params
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
)
|
)
|
||||||
@@ -76,3 +77,16 @@ func (h *ConnectionParametersManager) GetStreamFlowControlWindow() (protocol.Byt
|
|||||||
|
|
||||||
return protocol.ByteCount(value), nil
|
return protocol.ByteCount(value), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetIdleConnectionStateLifetime gets the idle timeout
|
||||||
|
func (h *ConnectionParametersManager) GetIdleConnectionStateLifetime() (time.Duration, error) {
|
||||||
|
rawValue, err := h.GetRawValue(TagICSL)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rawValue) != 4 {
|
||||||
|
return 0, errors.New("expected uint32 for ICSL")
|
||||||
|
}
|
||||||
|
return time.Duration(binary.LittleEndian.Uint32(rawValue)) * time.Second, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package handshake
|
package handshake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/protocol"
|
"github.com/lucas-clemente/quic-go/protocol"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@@ -57,4 +59,11 @@ var _ = Describe("ConnectionsParameterManager", func() {
|
|||||||
Expect(val).To(Equal(protocol.ByteCount(0xEFBEADDE)))
|
Expect(val).To(Equal(protocol.ByteCount(0xEFBEADDE)))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("gets idle connection state lifetime", func() {
|
||||||
|
cpm.params[TagICSL] = []byte{0xad, 0xfb, 0xca, 0xde}
|
||||||
|
val, err := cpm.GetIdleConnectionStateLifetime()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(val).To(Equal(0xdecafbad * time.Second))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user