Browse Source

Fix the use of ServerName in ECH config (#3188)

dyhkwong 1 year ago
parent
commit
13bad86c3b
1 changed files with 4 additions and 3 deletions
  1. 4 3
      transport/internet/tls/ech.go

+ 4 - 3
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
 		}