Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dns): avoid early return when dns query refused #2878

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

dop-bot
Copy link
Contributor

@dop-bot dop-bot commented Dec 30, 2023

The current code will not try other name servers when encounter RcodeRefused.

This happens, for example, if I am using a name server that is only accessible in certain area (office, school, etc), then I move to another place (home), which results in the previous name server refuse my DNS request, and the website browsering does not work at all (but it should try other servers with skipFallback to false, at least).

app/dns/dns.go Outdated
@@ -215,7 +216,10 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) {
newError("failed to lookup ip for domain ", domain, " at server ", client.Name()).Base(err).WriteToLog()
errs = append(errs, err)
}
if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse {
if dns.RCodeFromError(err) == dns_lib.RcodeRefused {
newError("DNS request for domain", domain, "got refused by server ", client.Name()).Base(err).AtError().WriteToLog()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you combine this error with line 216? E.g. only log once

app/dns/dns.go Outdated
@@ -9,6 +9,7 @@ import (
"strings"
"sync"

dns_lib "github.com/miekg/dns"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import this lib add quite a bit to the binary size. Can we hard code a constant for now?

@dop-bot
Copy link
Contributor Author

dop-bot commented Jan 2, 2024

Resolved @yuhan6665

@yuhan6665 yuhan6665 merged commit 60f7a03 into XTLS:main Jan 2, 2024
34 checks passed
@yuhan6665
Copy link
Member

Thanks for your pr!

@dop-bot
Copy link
Contributor Author

dop-bot commented Jan 2, 2024

Thank you and rprx for the effort too! Happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants