TLS ECH: Remove echForceQuery (ECH is forced now if configured) (#6032)

https://github.com/XTLS/Xray-core/pull/5887#issuecomment-4184701517
This commit is contained in:
风扇滑翔翼
2026-05-02 18:33:43 +08:00
committed by GitHub
parent 4e87f59628
commit 1fc6850dc4
4 changed files with 23 additions and 53 deletions
+6 -15
View File
@@ -3,6 +3,7 @@ package tls
import (
"io"
"net/http"
"slices"
"strings"
"sync"
"testing"
@@ -59,21 +60,11 @@ func TestECHDial(t *testing.T) {
func TestECHDialFail(t *testing.T) {
config := &Config{
ServerName: "cloudflare.com",
EchConfigList: "udp://127.0.0.1",
EchForceQuery: "half",
EchConfigList: "udp://0.0.0.0",
}
config.GetTLSConfig()
// check cache
echConfigCache, ok := GlobalECHConfigCache.Load(ECHCacheKey("udp://127.0.0.1", "cloudflare.com", nil))
if !ok {
t.Error("ECH config cache not found")
}
configRecord := echConfigCache.configRecord.Load()
if configRecord == nil {
t.Error("ECH config record not found in cache")
return
}
if configRecord.err == nil {
t.Error("unexpected nil error in ECH config record")
tlsConfig := config.GetTLSConfig()
ApplyECH(config, tlsConfig)
if !slices.Equal(tlsConfig.EncryptedClientHelloConfigList, []byte{1, 1, 4, 5, 1, 4}) {
t.Error("ECH config should be invalid when query failed", " but got ", tlsConfig.EncryptedClientHelloConfigList)
}
}