Skip to content

Commit 537c0d3

Browse files
authored
fix
1 parent 7b61584 commit 537c0d3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

infra/conf/transport_internet.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,8 @@ func (c *TLSConfig) Build() (proto.Message, error) {
494494
}
495495
config.EchServerKeys = EchPrivateKey
496496
}
497-
if c.ECHForceQuery == "" {
498-
c.ECHForceQuery = "none"
499-
}
500497
switch c.ECHForceQuery {
501-
case "none", "half", "full":
498+
case "none", "half", "full", "":
502499
config.EchForceQuery = c.ECHForceQuery
503500
default:
504501
return nil, errors.New(`invalid "echForceQuery": `, c.ECHForceQuery)

transport/internet/tls/ech.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@ func ApplyECH(c *Config, config *tls.Config) error {
5353

5454
// for client
5555
if len(c.EchConfigList) != 0 {
56-
switch c.EchForceQuery {
56+
ECHForceQuery := c.EchForceQuery
57+
switch ECHForceQuery {
5758
case "none", "half", "full":
5859
case "":
59-
c.EchForceQuery = "none" // default to none
60+
ECHForceQuery = "none" // default to none
6061
default:
6162
panic("Invalid ECHForceQuery: " + c.EchForceQuery)
6263
}
6364
defer func() {
6465
// if failed to get ECHConfig, use an invalid one to make connection fail
6566
if err != nil {
66-
if c.EchForceQuery == "full" {
67+
if ECHForceQuery == "full" {
6768
ECHConfig = []byte{1, 1, 4, 5, 1, 4}
6869
}
6970
}
@@ -144,7 +145,7 @@ func (c *ECHConfigCache) Update(domain string, server string, isLockedUpdate boo
144145
echConfig, ttl, err := dnsQuery(server, domain, sockopt)
145146
if err != nil {
146147
// only cache err if forceQuery is "none"
147-
if forceQuery == "none" || forceQuery == "" {
148+
if forceQuery != "none" {
148149
return nil, err
149150
}
150151
}

0 commit comments

Comments
 (0)