mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-30 16:29:57 +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{
|
||||
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)
|
||||
|
@ -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"`
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user