Skip to content

Commit ea2a68a

Browse files
authored
Skip if not go1.23
1 parent 4c7ca8b commit ea2a68a

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

transport/internet/tls/config.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,10 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
391391
}
392392
}
393393
if len(c.EchConfig) > 0 {
394-
ECHConfig, err := base64.StdEncoding.DecodeString(c.EchConfig)
394+
err := ApplyECH(c, config)
395395
if err != nil {
396-
errors.LogError(context.Background(), "invalid ECH config")
396+
errors.LogError(context.Background(), err)
397397
}
398-
config.EncryptedClientHelloConfigList = ECHConfig
399398
}
400399

401400
return config

transport/internet/tls/ech.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build go1.23
2+
// +build go1.23
3+
4+
package tls
5+
6+
import (
7+
"context"
8+
"crypto/tls"
9+
"encoding/base64"
10+
11+
"github.com/xtls/xray-core/common/errors"
12+
)
13+
14+
func ApplyECH(c *Config, config *tls.Config) error {
15+
ECHConfig, err := base64.StdEncoding.DecodeString(c.EchConfig)
16+
if err != nil {
17+
errors.LogError(context.Background(), "invalid ECH config")
18+
}
19+
config.EncryptedClientHelloConfigList = ECHConfig
20+
return nil
21+
}

transport/internet/tls/ech_go121.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//go:build !go1.23
2+
// +build !go1.23
3+
4+
package tls
5+
6+
import (
7+
"crypto/tls"
8+
9+
"github.com/xtls/xray-core/common/errors"
10+
)
11+
12+
func ApplyECH(c *Config, config *tls.Config) error {
13+
return errors.New("Win7 does not support ECH")
14+
}

0 commit comments

Comments
 (0)