Skip if not go1.23

This commit is contained in:
风扇滑翔翼 2024-09-15 05:17:39 +00:00 committed by GitHub
parent 4c7ca8beff
commit d7c2c33547
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 4 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/xtls/xray-core module github.com/xtls/xray-core
go 1.23 go 1.21.4
require ( require (
github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0

View File

@ -391,11 +391,10 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
} }
} }
if len(c.EchConfig) > 0 { if len(c.EchConfig) > 0 {
ECHConfig, err := base64.StdEncoding.DecodeString(c.EchConfig) err := ApplyECH(c, config)
if err != nil { if err != nil {
errors.LogError(context.Background(), "invalid ECH config") errors.LogError(context.Background(), err)
} }
config.EncryptedClientHelloConfigList = ECHConfig
} }
return config return config

View File

@ -0,0 +1,21 @@
//go:build go1.23
// +build go1.23
package tls
import (
"context"
"crypto/tls"
"encoding/base64"
"github.com/xtls/xray-core/common/errors"
)
func ApplyECH(c *Config, config *tls.Config) error {
ECHConfig, err := base64.StdEncoding.DecodeString(c.EchConfig)
if err != nil {
errors.LogError(context.Background(), "invalid ECH config")
}
config.EncryptedClientHelloConfigList = ECHConfig
return nil
}

View File

@ -0,0 +1,14 @@
//go:build !go1.23
// +build !go1.23
package tls
import (
"crypto/tls"
"github.com/xtls/xray-core/common/errors"
)
func ApplyECH(c *Config, config *tls.Config) error {
return errors.New("Win7 does not support ECH")
}