Skip to content

Commit

Permalink
proxy: imp log msg
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Oct 31, 2023
1 parent 20a0dda commit 543a9a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions proxy/dnscontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ type DNSContext struct {
// localIP - local IP address (for UDP socket to call udpMakeOOBWithSrc)
localIP net.IP

// QueryDuration is the time duration of the successful query from an
// upstream DNS server or a fallback DNS server, if exchange with an
// upstream wasn't successful.
// QueryDuration is the duration of the successful query from an upstream
// DNS server or a fallback DNS server, if exchange with an upstream wasn't
// successful.
QueryDuration time.Duration

// DoQVersion is the DoQ protocol version. It can (and should) be read from
Expand Down
7 changes: 5 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ func (p *Proxy) replyFromUpstream(d *DNSContext) (ok bool, err error) {
}

start := time.Now()
src := "upstream"

// Perform the DNS request.
resp, u, err := p.exchange(req, upstreams)
Expand All @@ -523,6 +524,7 @@ func (p *Proxy) replyFromUpstream(d *DNSContext) (ok bool, err error) {

// Reset the timer.
start = time.Now()
src = "fallback"

upstreams = p.Fallbacks.getUpstreamsForDomain(req.Question[0].Name)
if len(upstreams) == 0 {
Expand All @@ -533,9 +535,10 @@ func (p *Proxy) replyFromUpstream(d *DNSContext) (ok bool, err error) {
}

if resp != nil {
log.Debug("proxy: replying from upstream: rtt is %s", time.Since(start))
rtt := time.Since(start)
log.Debug("proxy: replying from %s: rtt is %s", src, rtt)

d.QueryDuration = time.Since(start)
d.QueryDuration = rtt
}

p.handleExchangeResult(d, req, resp, u)
Expand Down

0 comments on commit 543a9a9

Please sign in to comment.