sync: 0.42.0 merge commit

Signed-off-by: Gaukas Wang <i@gaukas.wang>
This commit is contained in:
Gaukas Wang 2024-04-23 22:38:23 -06:00
commit b66e1ed5f5
No known key found for this signature in database
GPG key ID: 6F0DF52D710D8189
2 changed files with 50 additions and 5 deletions

View file

@ -0,0 +1,50 @@
package qtls
import (
"crypto/tls"
"fmt"
"net"
"github.com/quic-go/quic-go/internal/testdata"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Setting the Cipher Suite", func() {
for _, cs := range []uint16{tls.TLS_AES_128_GCM_SHA256, tls.TLS_CHACHA20_POLY1305_SHA256, tls.TLS_AES_256_GCM_SHA384} {
cs := cs
It(fmt.Sprintf("selects %s", tls.CipherSuiteName(cs)), func() {
reset := SetCipherSuite(cs)
defer reset()
ln, err := tls.Listen("tcp4", "localhost:0", testdata.GetTLSConfig())
Expect(err).ToNot(HaveOccurred())
defer ln.Close()
done := make(chan struct{})
go func() {
defer GinkgoRecover()
defer close(done)
conn, err := ln.Accept()
Expect(err).ToNot(HaveOccurred())
_, err = conn.Read(make([]byte, 10))
Expect(err).ToNot(HaveOccurred())
Expect(conn.(*tls.Conn).ConnectionState().CipherSuite).To(Equal(cs))
}()
conn, err := tls.Dial(
"tcp4",
fmt.Sprintf("localhost:%d", ln.Addr().(*net.TCPAddr).Port),
&tls.Config{RootCAs: testdata.GetRootCA()},
)
Expect(err).ToNot(HaveOccurred())
_, err = conn.Write([]byte("foobar"))
Expect(err).ToNot(HaveOccurred())
Expect(conn.ConnectionState().CipherSuite).To(Equal(cs))
Expect(conn.Close()).To(Succeed())
Eventually(done).Should(BeClosed())
})
}
})

View file

@ -1,5 +0,0 @@
//go:build !go1.20
package qtls
var _ int = "The version of quic-go you're using can't be built using outdated Go versions. For more details, please see https://github.com/refraction-networking/uquic/wiki/quic-go-and-Go-versions."