diff --git a/cmd/client.go b/cmd/client.go index b8cdf1c..0fa84fe 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -30,9 +30,13 @@ func client(config *clientConfig) { tlsConfig := &tls.Config{ ServerName: config.ServerName, InsecureSkipVerify: config.Insecure, - NextProtos: []string{tlsProtocolName}, MinVersion: tls.VersionTLS13, } + if config.ALPN != "" { + tlsConfig.NextProtos = []string{config.ALPN} + } else { + tlsConfig.NextProtos = []string{DefaultALPN} + } // Load CA if len(config.CustomCA) > 0 { bs, err := ioutil.ReadFile(config.CustomCA) diff --git a/cmd/config.go b/cmd/config.go index 800c9a5..04cdbd7 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -13,7 +13,7 @@ const ( DefaultConnectionReceiveWindow = 67108864 // 64 MB/s DefaultMaxIncomingStreams = 1024 - tlsProtocolName = "hysteria" + DefaultALPN = "hysteria" ) type serverConfig struct { @@ -38,6 +38,7 @@ type serverConfig struct { Mode string `json:"mode"` Config json5.RawMessage `json:"config"` } `json:"auth"` + ALPN string `json:"alpn"` PrometheusListen string `json:"prometheus_listen"` ReceiveWindowConn uint64 `json:"recv_window_conn"` ReceiveWindowClient uint64 `json:"recv_window_client"` @@ -120,6 +121,7 @@ type clientConfig struct { Obfs string `json:"obfs"` Auth []byte `json:"auth"` AuthString string `json:"auth_str"` + ALPN string `json:"alpn"` ServerName string `json:"server_name"` Insecure bool `json:"insecure"` CustomCA string `json:"ca"` diff --git a/cmd/server.go b/cmd/server.go index dc56dfe..5bee50c 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -34,7 +34,6 @@ func server(config *serverConfig) { "error": err, }).Fatal("Failed to get a certificate with ACME") } - tc.NextProtos = []string{tlsProtocolName} tc.MinVersion = tls.VersionTLS13 tlsConfig = tc } else { @@ -49,10 +48,14 @@ func server(config *serverConfig) { } tlsConfig = &tls.Config{ Certificates: []tls.Certificate{cert}, - NextProtos: []string{tlsProtocolName}, MinVersion: tls.VersionTLS13, } } + if config.ALPN != "" { + tlsConfig.NextProtos = []string{config.ALPN} + } else { + tlsConfig.NextProtos = []string{DefaultALPN} + } // QUIC config quicConfig := &quic.Config{ InitialStreamReceiveWindow: config.ReceiveWindowConn,