Add h2Alpn option for TLS ClientHello

This commit is contained in:
wenyifan
2022-10-19 10:06:58 +08:00
parent ce15e23ce2
commit 85171b62b3
5 changed files with 110 additions and 76 deletions

View File

@ -85,6 +85,7 @@ type DialOptions struct {
Chain *Chain
Host string
HeaderConfig map[string]string
H2Alpn bool
}
// DialOption allows a common way to set DialOptions.
@ -118,6 +119,13 @@ func HeaderConfigDialOption(HeaderConfig map[string]string) DialOption {
}
}
// H2AlpnDialOption specifies is use HTTP2 in ALPN for TLS ClientHello
func H2AlpnDialOption(useH2Alpn bool) DialOption {
return func(opts *DialOptions) {
opts.H2Alpn = useH2Alpn
}
}
// HandshakeOptions describes the options for handshake.
type HandshakeOptions struct {
Addr string
@ -131,6 +139,7 @@ type HandshakeOptions struct {
KCPConfig *KCPConfig
QUICConfig *QUICConfig
SSHConfig *SSHConfig
H2Alpn bool
}
// HandshakeOption allows a common way to set HandshakeOptions.
@ -213,6 +222,13 @@ func SSHConfigHandshakeOption(config *SSHConfig) HandshakeOption {
}
}
// H2AlpnHandshakeOption specifies is use HTTP2 in ALPN for TLS ClientHello.
func H2AlpnHandshakeOption(useH2Alpn bool) HandshakeOption {
return func(opts *HandshakeOptions) {
opts.H2Alpn = useH2Alpn
}
}
// ConnectOptions describes the options for Connector.Connect.
type ConnectOptions struct {
Addr string