mirror of
https://github.com/cedar2025/hysteria.git
synced 2025-07-05 02:39:51 +00:00
feat: customizable ALPN
This commit is contained in:
parent
db01b7000e
commit
4140927003
@ -30,9 +30,13 @@ func client(config *clientConfig) {
|
|||||||
tlsConfig := &tls.Config{
|
tlsConfig := &tls.Config{
|
||||||
ServerName: config.ServerName,
|
ServerName: config.ServerName,
|
||||||
InsecureSkipVerify: config.Insecure,
|
InsecureSkipVerify: config.Insecure,
|
||||||
NextProtos: []string{tlsProtocolName},
|
|
||||||
MinVersion: tls.VersionTLS13,
|
MinVersion: tls.VersionTLS13,
|
||||||
}
|
}
|
||||||
|
if config.ALPN != "" {
|
||||||
|
tlsConfig.NextProtos = []string{config.ALPN}
|
||||||
|
} else {
|
||||||
|
tlsConfig.NextProtos = []string{DefaultALPN}
|
||||||
|
}
|
||||||
// Load CA
|
// Load CA
|
||||||
if len(config.CustomCA) > 0 {
|
if len(config.CustomCA) > 0 {
|
||||||
bs, err := ioutil.ReadFile(config.CustomCA)
|
bs, err := ioutil.ReadFile(config.CustomCA)
|
||||||
|
@ -13,7 +13,7 @@ const (
|
|||||||
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
DefaultConnectionReceiveWindow = 67108864 // 64 MB/s
|
||||||
DefaultMaxIncomingStreams = 1024
|
DefaultMaxIncomingStreams = 1024
|
||||||
|
|
||||||
tlsProtocolName = "hysteria"
|
DefaultALPN = "hysteria"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serverConfig struct {
|
type serverConfig struct {
|
||||||
@ -38,6 +38,7 @@ type serverConfig struct {
|
|||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
Config json5.RawMessage `json:"config"`
|
Config json5.RawMessage `json:"config"`
|
||||||
} `json:"auth"`
|
} `json:"auth"`
|
||||||
|
ALPN string `json:"alpn"`
|
||||||
PrometheusListen string `json:"prometheus_listen"`
|
PrometheusListen string `json:"prometheus_listen"`
|
||||||
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
ReceiveWindowConn uint64 `json:"recv_window_conn"`
|
||||||
ReceiveWindowClient uint64 `json:"recv_window_client"`
|
ReceiveWindowClient uint64 `json:"recv_window_client"`
|
||||||
@ -120,6 +121,7 @@ type clientConfig struct {
|
|||||||
Obfs string `json:"obfs"`
|
Obfs string `json:"obfs"`
|
||||||
Auth []byte `json:"auth"`
|
Auth []byte `json:"auth"`
|
||||||
AuthString string `json:"auth_str"`
|
AuthString string `json:"auth_str"`
|
||||||
|
ALPN string `json:"alpn"`
|
||||||
ServerName string `json:"server_name"`
|
ServerName string `json:"server_name"`
|
||||||
Insecure bool `json:"insecure"`
|
Insecure bool `json:"insecure"`
|
||||||
CustomCA string `json:"ca"`
|
CustomCA string `json:"ca"`
|
||||||
|
@ -34,7 +34,6 @@ func server(config *serverConfig) {
|
|||||||
"error": err,
|
"error": err,
|
||||||
}).Fatal("Failed to get a certificate with ACME")
|
}).Fatal("Failed to get a certificate with ACME")
|
||||||
}
|
}
|
||||||
tc.NextProtos = []string{tlsProtocolName}
|
|
||||||
tc.MinVersion = tls.VersionTLS13
|
tc.MinVersion = tls.VersionTLS13
|
||||||
tlsConfig = tc
|
tlsConfig = tc
|
||||||
} else {
|
} else {
|
||||||
@ -49,10 +48,14 @@ func server(config *serverConfig) {
|
|||||||
}
|
}
|
||||||
tlsConfig = &tls.Config{
|
tlsConfig = &tls.Config{
|
||||||
Certificates: []tls.Certificate{cert},
|
Certificates: []tls.Certificate{cert},
|
||||||
NextProtos: []string{tlsProtocolName},
|
|
||||||
MinVersion: tls.VersionTLS13,
|
MinVersion: tls.VersionTLS13,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if config.ALPN != "" {
|
||||||
|
tlsConfig.NextProtos = []string{config.ALPN}
|
||||||
|
} else {
|
||||||
|
tlsConfig.NextProtos = []string{DefaultALPN}
|
||||||
|
}
|
||||||
// QUIC config
|
// QUIC config
|
||||||
quicConfig := &quic.Config{
|
quicConfig := &quic.Config{
|
||||||
InitialStreamReceiveWindow: config.ReceiveWindowConn,
|
InitialStreamReceiveWindow: config.ReceiveWindowConn,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user