瀏覽代碼

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

dyhkwong 1 年之前
父節點
當前提交
13bad86c3b
共有 1 個文件被更改,包括 4 次插入3 次删除
  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
 		}