From 6aace7b1b718b0469e57eb4a043b1e7a16534a58 Mon Sep 17 00:00:00 2001 From: ReleTor <191429954+ReleTor@users.noreply.github.com> Date: Sun, 6 Apr 2025 20:33:13 +0800 Subject: [PATCH] Fix fetch ECH configs --- common/tls/ech.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/tls/ech.go b/common/tls/ech.go index 880ca27c..ddb9b5dd 100644 --- a/common/tls/ech.go +++ b/common/tls/ech.go @@ -123,6 +123,7 @@ func (s *STDECHClientConfig) ClientHandshake(ctx context.Context, conn net.Conn) if response.Rcode != mDNS.RcodeSuccess { return nil, E.Cause(dns.RcodeError(response.Rcode), "fetch ECH config list") } + match: for _, rr := range response.Answer { switch resource := rr.(type) { case *mDNS.HTTPS: @@ -133,11 +134,14 @@ func (s *STDECHClientConfig) ClientHandshake(ctx context.Context, conn net.Conn) return nil, E.Cause(err, "decode ECH config") } s.config.EncryptedClientHelloConfigList = echConfigList + break match } } } } - return nil, E.New("no ECH config found in DNS records") + if len(s.config.EncryptedClientHelloConfigList) == 0 { + return nil, E.New("no ECH config found in DNS records") + } } tlsConn, err := s.Client(conn) if err != nil {