Skip to content

Commit

Permalink
Don`t cache error from lookup transport
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Sep 21, 2023
1 parent b33dbd8 commit fc3e4c0
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,7 @@ func (c *Client) Lookup(ctx context.Context, transport Transport, domain string,
var rCode int
response, err := transport.Lookup(ctx, domain, strategy)
if err != nil {
err = wrapError(err)
if rCodeError, isRCodeError := err.(RCodeError); !isRCodeError {
return nil, err
} else {
rCode = int(rCodeError)
}
if disableCache {
return nil, err
}
return nil, wrapError(err)
}
header := dns.MsgHdr{
Response: true,
Expand Down Expand Up @@ -306,7 +298,7 @@ func (c *Client) Lookup(ctx context.Context, transport Transport, domain string,
c.storeCache(transport, question6, message6, int(timeToLive))
}
}
return response, err
return response, nil
}

func (c *Client) ClearCache() {
Expand Down Expand Up @@ -375,20 +367,14 @@ func (c *Client) exchangeToLookup(ctx context.Context, transport Transport, mess
} else {
strategy = DomainStrategyUseIPv6
}
var rCode int
result, err := c.Lookup(ctx, transport, domain, strategy)
if err != nil {
err = wrapError(err)
if rCodeError, isRCodeError := err.(RCodeError); !isRCodeError {
return nil, err
} else {
rCode = int(rCodeError)
}
return nil, wrapError(err)
}
response := dns.Msg{
MsgHdr: dns.MsgHdr{
Id: message.Id,
Rcode: rCode,
Rcode: dns.RcodeSuccess,
Response: true,
},
Question: message.Question,
Expand Down

0 comments on commit fc3e4c0

Please sign in to comment.