mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-26 16:57:08 +00:00
chore: update quic-go to 0.57.1
This commit is contained in:
@@ -2,7 +2,6 @@ package dns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
@@ -12,6 +11,7 @@ import (
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
|
||||
"github.com/metacubex/tls"
|
||||
D "github.com/miekg/dns"
|
||||
)
|
||||
|
||||
|
||||
20
dns/doh.go
20
dns/doh.go
@@ -2,13 +2,11 @@ package dns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@@ -16,15 +14,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/metacubex/mihomo/component/ca"
|
||||
tlsC "github.com/metacubex/mihomo/component/tls"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
|
||||
"github.com/metacubex/http"
|
||||
"github.com/metacubex/quic-go"
|
||||
"github.com/metacubex/quic-go/http3"
|
||||
"github.com/metacubex/tls"
|
||||
D "github.com/miekg/dns"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/net/http2"
|
||||
)
|
||||
|
||||
// Values to configure HTTP and HTTP/2 transport.
|
||||
@@ -439,8 +437,8 @@ func (doh *dnsOverHTTPS) createTransport(ctx context.Context) (t http.RoundTripp
|
||||
// Explicitly configure transport to use HTTP/2.
|
||||
//
|
||||
// See https://github.com/AdguardTeam/dnsproxy/issues/11.
|
||||
var transportH2 *http2.Transport
|
||||
transportH2, err = http2.ConfigureTransports(transport)
|
||||
var transportH2 *http.Http2Transport
|
||||
transportH2, err = http.Http2ConfigureTransports(transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -530,20 +528,20 @@ func (doh *dnsOverHTTPS) createTransportH3(
|
||||
// Ignore the address and always connect to the one that we got
|
||||
// from the bootstrapper.
|
||||
_ string,
|
||||
tlsCfg *tlsC.Config,
|
||||
tlsCfg *tls.Config,
|
||||
cfg *quic.Config,
|
||||
) (c *quic.Conn, err error) {
|
||||
return doh.dialQuic(ctx, addr, tlsCfg, cfg)
|
||||
},
|
||||
DisableCompression: true,
|
||||
TLSClientConfig: tlsC.UConfig(tlsConfig),
|
||||
TLSClientConfig: tlsConfig,
|
||||
QUICConfig: doh.getQUICConfig(),
|
||||
}
|
||||
|
||||
return &http3Transport{baseTransport: rt}, nil
|
||||
}
|
||||
|
||||
func (doh *dnsOverHTTPS) dialQuic(ctx context.Context, addr string, tlsCfg *tlsC.Config, cfg *quic.Config) (*quic.Conn, error) {
|
||||
func (doh *dnsOverHTTPS) dialQuic(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (*quic.Conn, error) {
|
||||
ip, port, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -612,7 +610,7 @@ func (doh *dnsOverHTTPS) probeH3(
|
||||
// Run probeQUIC and probeTLS in parallel and see which one is faster.
|
||||
chQuic := make(chan error, 1)
|
||||
chTLS := make(chan error, 1)
|
||||
go doh.probeQUIC(ctx, addr, tlsC.UConfig(probeTLSCfg), chQuic)
|
||||
go doh.probeQUIC(ctx, addr, probeTLSCfg, chQuic)
|
||||
go doh.probeTLS(ctx, probeTLSCfg, chTLS)
|
||||
|
||||
select {
|
||||
@@ -637,7 +635,7 @@ func (doh *dnsOverHTTPS) probeH3(
|
||||
|
||||
// probeQUIC attempts to establish a QUIC connection to the specified address.
|
||||
// We run probeQUIC and probeTLS in parallel and see which one is faster.
|
||||
func (doh *dnsOverHTTPS) probeQUIC(ctx context.Context, addr string, tlsConfig *tlsC.Config, ch chan error) {
|
||||
func (doh *dnsOverHTTPS) probeQUIC(ctx context.Context, addr string, tlsConfig *tls.Config, ch chan error) {
|
||||
startTime := time.Now()
|
||||
conn, err := doh.dialQuic(ctx, addr, tlsConfig, doh.getQUICConfig())
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package dns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -13,11 +12,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/metacubex/mihomo/component/ca"
|
||||
tlsC "github.com/metacubex/mihomo/component/tls"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
|
||||
"github.com/metacubex/quic-go"
|
||||
"github.com/metacubex/tls"
|
||||
D "github.com/miekg/dns"
|
||||
)
|
||||
|
||||
@@ -348,7 +347,7 @@ func (doq *dnsOverQUIC) openConnection(ctx context.Context) (conn *quic.Conn, er
|
||||
transport := quic.Transport{Conn: udp}
|
||||
transport.SetCreatedConn(true) // auto close conn
|
||||
transport.SetSingleUse(true) // auto close transport
|
||||
conn, err = transport.Dial(ctx, &udpAddr, tlsC.UConfig(tlsConfig), doq.getQUICConfig())
|
||||
conn, err = transport.Dial(ctx, &udpAddr, tlsConfig, doq.getQUICConfig())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("opening quic connection to %s: %w", doq.addr, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user