This commit is contained in:
wenyifan
2023-11-15 17:49:38 +08:00
parent 3038eb66d8
commit 34b9e3b16e
4 changed files with 22 additions and 4 deletions

View File

@ -174,8 +174,13 @@ func (d *mwsDialer) initSession(ctx context.Context, host string, conn net.Conn,
}) })
} }
} }
client := tls.UClient(conn, utlsConf, tls.HelloCustom) var client *tls.UConn
client.ApplyPreset(util.NewWsSpec()) if d.md.useH2 {
client = tls.UClient(conn, utlsConf, tls.HelloChrome_Auto)
} else {
client = tls.UClient(conn, utlsConf, tls.HelloCustom)
client.ApplyPreset(util.NewWsSpec())
}
err := client.Handshake() err := client.Handshake()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -27,6 +27,9 @@ type metadata struct {
header http.Header header http.Header
keepaliveInterval time.Duration keepaliveInterval time.Duration
muxCfg *mux.Config muxCfg *mux.Config
//Evan Enhanced
useH2 bool
} }
func (d *mwsDialer) parseMetadata(md mdata.Metadata) (err error) { func (d *mwsDialer) parseMetadata(md mdata.Metadata) (err error) {
@ -67,5 +70,6 @@ func (d *mwsDialer) parseMetadata(md mdata.Metadata) (err error) {
} }
} }
d.md.useH2 = mdutil.GetBool(md, "h2")
return return
} }

View File

@ -111,8 +111,13 @@ func (d *wsDialer) Handshake(ctx context.Context, conn net.Conn, options ...dial
}) })
} }
} }
client := tls.UClient(conn, utlsConf, tls.HelloCustom) var client *tls.UConn
client.ApplyPreset(util.NewWsSpec()) if d.md.useH2 {
client = tls.UClient(conn, utlsConf, tls.HelloChrome_Auto)
} else {
client = tls.UClient(conn, utlsConf, tls.HelloCustom)
client.ApplyPreset(util.NewWsSpec())
}
err := client.Handshake() err := client.Handshake()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -25,6 +25,9 @@ type metadata struct {
header http.Header header http.Header
keepaliveInterval time.Duration keepaliveInterval time.Duration
//Evan Enhance
useH2 bool
} }
func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) { func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
@ -56,5 +59,6 @@ func (d *wsDialer) parseMetadata(md mdata.Metadata) (err error) {
} }
} }
d.md.useH2 = mdutil.GetBool(md, "h2")
return return
} }