Skip to content

Commit

Permalink
Correct cache behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Fangliding authored Sep 15, 2024
1 parent d2e79c2 commit 331718b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion transport/internet/tls/ech.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ func QueryRecord(domain string, server string) (string, error) {
defer mutex.RUnlock()
rec, found := dnsCache[domain]
if found && rec.expire.After(time.Now()) {
return "", nil
return rec.record, nil
}
mutex.Lock()
defer mutex.Unlock()
record, err := dohQuery(server, domain)
if err != nil {
return "", err
}
rec.record = record
rec.expire = time.Now().Add(time.Second * 600)
dnsCache[domain] = rec
return record, nil
}

Expand Down

0 comments on commit 331718b

Please sign in to comment.