remove the host parameter from all dial functions

This commit is contained in:
Marten Seemann 2023-04-01 18:40:26 +09:00
parent ea721c9c75
commit d683b841c4
14 changed files with 43 additions and 237 deletions

View file

@ -36,7 +36,7 @@ func BenchmarkHandshake(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
c, err := quic.Dial(conn, ln.Addr(), "localhost", tlsClientConfig, nil)
c, err := quic.Dial(conn, ln.Addr(), tlsClientConfig, nil)
if err != nil {
b.Fatal(err)
}

View file

@ -107,7 +107,6 @@ var _ = Describe("Datagram test", func() {
conn, err := quic.Dial(
clientConn,
raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(),
getQuicConfig(&quic.Config{EnableDatagrams: true}),
)
@ -143,7 +142,6 @@ var _ = Describe("Datagram test", func() {
conn, err := quic.Dial(
clientConn,
raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(),
getQuicConfig(&quic.Config{EnableDatagrams: true}),
)
@ -161,7 +159,6 @@ var _ = Describe("Datagram test", func() {
conn, err := quic.Dial(
clientConn,
raddr,
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
getTLSClientConfig(),
getQuicConfig(&quic.Config{EnableDatagrams: true}),
)

View file

@ -152,11 +152,12 @@ var _ = Describe("Handshake tests", func() {
runServer(getTLSConfig())
conn, err := net.ListenUDP("udp", nil)
Expect(err).ToNot(HaveOccurred())
conf := getTLSClientConfig()
conf.ServerName = "foo.bar"
_, err = quic.Dial(
conn,
server.Addr(),
"foo.bar",
getTLSClientConfig(),
conf,
getQuicConfig(nil),
)
Expect(err).To(HaveOccurred())
@ -222,13 +223,7 @@ var _ = Describe("Handshake tests", func() {
remoteAddr := fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
raddr, err := net.ResolveUDPAddr("udp", remoteAddr)
Expect(err).ToNot(HaveOccurred())
return quic.Dial(
pconn,
raddr,
remoteAddr,
getTLSClientConfig(),
nil,
)
return quic.Dial(pconn, raddr, getTLSClientConfig(), nil)
}
BeforeEach(func() {

View file

@ -2,7 +2,6 @@ package self_test
import (
"context"
"crypto/tls"
"io"
"net"
"net/http"
@ -12,7 +11,6 @@ import (
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/http3"
"github.com/quic-go/quic-go/internal/testdata"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -84,17 +82,14 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
server1 = &http3.Server{
Handler: mux1,
TLSConfig: testdata.GetTLSConfig(),
QuicConfig: getQuicConfig(nil),
}
server2 = &http3.Server{
Handler: mux2,
TLSConfig: testdata.GetTLSConfig(),
QuicConfig: getQuicConfig(nil),
}
tlsConf := http3.ConfigureTLSConfig(testdata.GetTLSConfig())
tlsConf := http3.ConfigureTLSConfig(getTLSConfig())
quicln, err := quic.ListenAddrEarly("0.0.0.0:0", tlsConf, getQuicConfig(nil))
ln = &listenerWrapper{EarlyListener: quicln}
Expect(err).NotTo(HaveOccurred())
@ -108,9 +103,7 @@ var _ = Describe("HTTP3 Server hotswap test", func() {
BeforeEach(func() {
client = &http.Client{
Transport: &http3.RoundTripper{
TLSClientConfig: &tls.Config{
RootCAs: testdata.GetRootCA(),
},
TLSClientConfig: getTLSClientConfig(),
DisableCompression: true,
QuicConfig: getQuicConfig(&quic.Config{MaxIdleTimeout: 10 * time.Second}),
},

View file

@ -5,7 +5,6 @@ import (
"bytes"
"compress/gzip"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
@ -15,11 +14,11 @@ import (
"strconv"
"time"
"golang.org/x/sync/errgroup"
"github.com/quic-go/quic-go"
"github.com/quic-go/quic-go/http3"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/testdata"
"golang.org/x/sync/errgroup"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -80,7 +79,7 @@ var _ = Describe("HTTP tests", func() {
server = &http3.Server{
Handler: mux,
TLSConfig: testdata.GetTLSConfig(),
TLSConfig: getTLSConfig(),
QuicConfig: getQuicConfig(nil),
}
@ -107,9 +106,7 @@ var _ = Describe("HTTP tests", func() {
BeforeEach(func() {
client = &http.Client{
Transport: &http3.RoundTripper{
TLSClientConfig: &tls.Config{
RootCAs: testdata.GetRootCA(),
},
TLSClientConfig: getTLSClientConfig(),
DisableCompression: true,
QuicConfig: getQuicConfig(&quic.Config{MaxIdleTimeout: 10 * time.Second}),
},
@ -381,7 +378,7 @@ var _ = Describe("HTTP tests", func() {
if version == protocol.VersionDraft29 {
Skip("This test only works on RFC versions")
}
tlsConf := testdata.GetTLSConfig()
tlsConf := getTLSConfig()
tlsConf.NextProtos = []string{"h3"}
ln, err := quic.ListenAddr("localhost:0", tlsConf, nil)
Expect(err).ToNot(HaveOccurred())

View file

@ -149,7 +149,6 @@ var _ = Describe("MITM test", func() {
conn, err := quic.Dial(
clientUDPConn,
raddr,
fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(),
getQuicConfig(&quic.Config{ConnectionIDLength: connIDLen}),
)
@ -193,7 +192,6 @@ var _ = Describe("MITM test", func() {
conn, err := quic.Dial(
clientUDPConn,
raddr,
fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(),
getQuicConfig(&quic.Config{ConnectionIDLength: connIDLen}),
)
@ -308,7 +306,6 @@ var _ = Describe("MITM test", func() {
_, err = quic.Dial(
clientUDPConn,
raddr,
fmt.Sprintf("localhost:%d", proxyPort),
getTLSClientConfig(),
getQuicConfig(&quic.Config{
ConnectionIDLength: connIDLen,

View file

@ -2,7 +2,6 @@ package self_test
import (
"context"
"fmt"
"io"
"net"
"runtime"
@ -39,7 +38,6 @@ var _ = Describe("Multiplexing", func() {
conn, err := quic.Dial(
pconn,
addr,
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
getTLSClientConfig(),
getQuicConfig(nil),
)

View file

@ -127,6 +127,7 @@ func init() {
root := x509.NewCertPool()
root.AddCert(ca)
tlsClientConfig = &tls.Config{
ServerName: "localhost",
RootCAs: root,
NextProtos: []string{alpn},
}

View file

@ -486,7 +486,6 @@ var _ = Describe("Timeout tests", func() {
conn, err := quic.Dial(
&faultyConn{PacketConn: conn, MaxPackets: maxPackets},
ln.Addr(),
"localhost",
getTLSClientConfig(),
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
)

View file

@ -44,6 +44,7 @@ func init() {
root := x509.NewCertPool()
root.AddCert(ca)
tlsClientConfig = &tls.Config{
ServerName: "localhost",
RootCAs: root,
NextProtos: []string{tools.ALPN},
}