From 13bad86c3b1570f5e203a29a82afd4b843d612a1 Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Sun, 13 Oct 2024 02:59:43 +0800 Subject: [PATCH] Fix the use of ServerName in ECH config (#3188) --- transport/internet/tls/ech.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/transport/internet/tls/ech.go b/transport/internet/tls/ech.go index 8b012250e86..41be26d9db8 100644 --- a/transport/internet/tls/ech.go +++ b/transport/internet/tls/ech.go @@ -24,10 +24,11 @@ func ApplyECH(c *Config, config *tls.Config) error { if len(c.EchConfig) > 0 { ECHConfig = c.EchConfig } else { // ECH config > DOH lookup - if config.ServerName == "" { - return newError("Using DOH for ECH needs serverName") + addr := net.ParseAddress(config.ServerName) + if !addr.Family().IsDomain() { + return newError("Using DOH for ECH needs SNI") } - ECHConfig, err = QueryRecord(c.ServerName, c.Ech_DOHserver) + ECHConfig, err = QueryRecord(addr.Domain(), c.Ech_DOHserver) if err != nil { return err }