mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 14:56:47 +00:00
chore: using new net/http api in reality client fallback
This commit is contained in:
1 parent
7a646e8d10
commit
a1c68a4346
1 file changed
+8
-4
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
"github.com/metacubex/http"
|
||||
"github.com/metacubex/randv2"
|
||||
"github.com/metacubex/tls"
|
||||
utls "github.com/metacubex/utls"
|
||||
"golang.org/x/crypto/hkdf"
|
||||
)
|
||||
@@ -134,11 +133,16 @@ func GetRealityConn(ctx context.Context, conn net.Conn, fingerprint UClientHello
|
||||
|
||||
func realityClientFallback(uConn net.Conn, serverName string, fingerprint utls.ClientHelloID) {
|
||||
defer uConn.Close()
|
||||
// use h2c mode to disallow the net/http fallback to http1.1
|
||||
protocols := new(http.Protocols)
|
||||
protocols.SetUnencryptedHTTP2(true)
|
||||
client := http.Client{
|
||||
Transport: &http.Http2Transport{
|
||||
DialTLSContext: func(ctx context.Context, network, addr string, config *tls.Config) (net.Conn, error) {
|
||||
return uConn, nil
|
||||
Transport: &http.Transport{
|
||||
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
type netConn struct{ net.Conn } // hide tls-type to skip ALPN check and force enter h2 mode
|
||||
return netConn{uConn}, nil
|
||||
},
|
||||
Protocols: protocols,
|
||||
},
|
||||
}
|
||||
request, err := http.NewRequest("GET", "https://"+serverName, nil)
|
||||
|
||||
Reference in new issue
Block a user