forked from quic-go/quic-go
simplify version negotiation in the client
This commit is contained in:
11
client.go
11
client.go
@@ -23,7 +23,6 @@ type client struct {
|
||||
conn connection
|
||||
hostname string
|
||||
|
||||
versionNegotiationChan chan struct{} // the versionNegotiationChan is closed as soon as the server accepted the suggested version
|
||||
versionNegotiated bool // has the server accepted our version
|
||||
receivedVersionNegotiationPacket bool
|
||||
negotiatedVersions []protocol.VersionNumber // the list of versions from the version negotiation packet
|
||||
@@ -113,7 +112,6 @@ func Dial(
|
||||
tlsConf: tlsConf,
|
||||
config: clientConfig,
|
||||
version: version,
|
||||
versionNegotiationChan: make(chan struct{}),
|
||||
logger: utils.DefaultLogger,
|
||||
}
|
||||
|
||||
@@ -256,13 +254,6 @@ func (c *client) establishSecureConnection() error {
|
||||
}
|
||||
}()
|
||||
|
||||
// wait until the server accepts the QUIC version (or an error occurs)
|
||||
select {
|
||||
case <-errorChan:
|
||||
return runErr
|
||||
case <-c.versionNegotiationChan:
|
||||
}
|
||||
|
||||
select {
|
||||
case <-errorChan:
|
||||
return runErr
|
||||
@@ -361,7 +352,6 @@ func (c *client) handleIETFQUICPacket(hdr *wire.Header, packetData []byte, remot
|
||||
// since it is not a Version Negotiation Packet, this means the server supports the suggested version
|
||||
if !c.versionNegotiated {
|
||||
c.versionNegotiated = true
|
||||
close(c.versionNegotiationChan)
|
||||
}
|
||||
|
||||
c.session.handlePacket(&receivedPacket{
|
||||
@@ -399,7 +389,6 @@ func (c *client) handleGQUICPacket(hdr *wire.Header, r *bytes.Reader, packetData
|
||||
// since it is not a Version Negotiation Packet, this means the server supports the suggested version
|
||||
if !c.versionNegotiated {
|
||||
c.versionNegotiated = true
|
||||
close(c.versionNegotiationChan)
|
||||
}
|
||||
|
||||
c.session.handlePacket(&receivedPacket{
|
||||
|
||||
@@ -60,7 +60,6 @@ var _ = Describe("Client", func() {
|
||||
session: sess,
|
||||
version: protocol.SupportedVersions[0],
|
||||
conn: &conn{pconn: packetConn, currentAddr: addr},
|
||||
versionNegotiationChan: make(chan struct{}),
|
||||
logger: utils.DefaultLogger,
|
||||
}
|
||||
})
|
||||
@@ -382,7 +381,6 @@ var _ = Describe("Client", func() {
|
||||
err = cl.handlePacket(nil, b.Bytes())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(cl.versionNegotiated).To(BeTrue())
|
||||
Expect(cl.versionNegotiationChan).To(BeClosed())
|
||||
})
|
||||
|
||||
It("changes the version after receiving a version negotiation packet", func() {
|
||||
|
||||
Reference in New Issue
Block a user