Missing rename

pull/3813/head
风扇滑翔翼 2025-03-09 13:30:15 +00:00 committed by GitHub
parent 7f6a825bfe
commit 4999fd5b7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -22,7 +22,7 @@ func ApplyECH(c *Config, config *tls.Config) error {
var err error var err error
nameToQuery := c.ServerName nameToQuery := c.ServerName
var DOHServer string var DNSServer string
// for client // for client
if len(c.EchConfigList) != 0 { if len(c.EchConfigList) != 0 {
@ -37,19 +37,19 @@ func ApplyECH(c *Config, config *tls.Config) error {
} else { // query config from dns } else { // query config from dns
parts := strings.Split(c.EchConfigList, "+") parts := strings.Split(c.EchConfigList, "+")
if len(parts) == 2 { if len(parts) == 2 {
// parse ECH DOH server in format of "example.com+https://1.1.1.1/dns-query" // parse ECH DNS server in format of "example.com+https://1.1.1.1/dns-query"
nameToQuery = parts[0] nameToQuery = parts[0]
DOHServer = parts[1] DNSServer = parts[1]
} else if len(parts) == 1 { } else if len(parts) == 1 {
// normal format // normal format
DOHServer = parts[0] DNSServer = parts[0]
} else { } else {
return errors.New("Invalid ECH DNS server format: ", c.EchConfigList) return errors.New("Invalid ECH DNS server format: ", c.EchConfigList)
} }
if nameToQuery == "" { if nameToQuery == "" {
return errors.New("Using DOH for ECH needs serverName or use dohServer format example.com+https://1.1.1.1/dns-query") return errors.New("Using DNS for ECH Config needs serverName or use Server format example.com+https://1.1.1.1/dns-query")
} }
ECHConfig, err = QueryRecord(nameToQuery, DOHServer) ECHConfig, err = QueryRecord(nameToQuery, DNSServer)
if err != nil { if err != nil {
return err return err
} }
@ -94,7 +94,7 @@ var (
) )
// QueryRecord returns the ECH config for given domain. // QueryRecord returns the ECH config for given domain.
// If the record is not in cache or expired, it will query the DOH server and update the cache. // If the record is not in cache or expired, it will query the DNS server and update the cache.
func QueryRecord(domain string, server string) ([]byte, error) { func QueryRecord(domain string, server string) ([]byte, error) {
val, found := dnsCache.Load(domain) val, found := dnsCache.Load(domain)
rec, _ := val.(record) rec, _ := val.(record)
@ -114,9 +114,9 @@ func QueryRecord(domain string, server string) ([]byte, error) {
return rec.echConfig, nil return rec.echConfig, nil
} }
// Query ECH config from DOH server // Query ECH config from DNS server
errors.LogDebug(context.Background(), "Trying to query ECH config for domain: ", domain, " with ECH server: ", server) errors.LogDebug(context.Background(), "Trying to query ECH config for domain: ", domain, " with ECH server: ", server)
echConfig, ttl, err := dohQuery(server, domain) echConfig, ttl, err := dnsQuery(server, domain)
if err != nil { if err != nil {
return []byte{}, err return []byte{}, err
} }
@ -135,9 +135,9 @@ func QueryRecord(domain string, server string) ([]byte, error) {
return echConfig, nil return echConfig, nil
} }
// dohQuery is the real func for sending type65 query for given domain to given DOH server. // dnsQuery is the real func for sending type65 query for given domain to given DNS server.
// return ECH config, TTL and error // return ECH config, TTL and error
func dohQuery(server string, domain string) ([]byte, uint32, error) { func dnsQuery(server string, domain string) ([]byte, uint32, error) {
m := new(dns.Msg) m := new(dns.Msg)
var dnsResolve []byte var dnsResolve []byte
m.SetQuestion(dns.Fqdn(domain), dns.TypeHTTPS) m.SetQuestion(dns.Fqdn(domain), dns.TypeHTTPS)