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 cache with empty response #1183

Merged

Conversation

rurirei
Copy link
Contributor

@rurirei rurirei commented Aug 4, 2021

this provides a fix that the dns app won't do cache with the IPRecord with a empty address (len(rec.IP == 0)).

[v2ray] [Info] v2ray.com/core/app/dns: DOHL//dns.google got answer: x.xxx. TypeA -> []
[v2ray] [Info] v2ray.com/core/app/dns: DOHL//dns.google cache HIT x.xxx -> [] > empty response

extensive review is expected @xiaokangwang

@rurirei rurirei marked this pull request as draft August 4, 2021 01:52
@Loyalsoldier Loyalsoldier marked this pull request as ready for review August 9, 2021 22:46
@Loyalsoldier Loyalsoldier force-pushed the fix_dns_cache_emptyresponse branch 2 times, most recently from bb36949 to 9670d2f Compare August 10, 2021 00:23
@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2021

Codecov Report

Merging #1183 (b08d67f) into master (e0a73e5) will decrease coverage by 0.07%.
The diff coverage is 76.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1183      +/-   ##
==========================================
- Coverage   44.82%   44.75%   -0.08%     
==========================================
  Files         485      484       -1     
  Lines       29494    29477      -17     
==========================================
- Hits        13221    13191      -30     
- Misses      14872    14884      +12     
- Partials     1401     1402       +1     
Impacted Files Coverage Δ
app/dns/dnscommon.go 87.87% <0.00%> (+1.51%) ⬆️
app/dns/nameserver_tcp.go 69.04% <72.72%> (+1.41%) ⬆️
app/dns/nameserver_doh.go 68.98% <75.00%> (+2.00%) ⬆️
app/dns/nameserver_quic.go 73.95% <75.00%> (+1.99%) ⬆️
app/dns/nameserver_udp.go 81.43% <85.71%> (-0.16%) ⬇️
transport/internet/udp/dispatcher.go 64.76% <0.00%> (-12.39%) ⬇️
common/buf/reader.go 82.35% <0.00%> (-5.89%) ⬇️
transport/internet/udp/hub.go 73.61% <0.00%> (-4.17%) ⬇️
proxy/freedom/freedom.go 45.00% <0.00%> (-4.00%) ⬇️
transport/internet/system_listener.go 50.00% <0.00%> (-4.00%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0a73e5...b08d67f. Read the comment docs.

@Loyalsoldier Loyalsoldier merged commit 73470e8 into v2fly:master Aug 10, 2021
@Loyalsoldier
Copy link
Contributor

The empty response without IP addresses does have error code and other messages in it, we need to store it and detect it later.

Comment on lines -324 to -325
if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) {
return nil, dns_feature.ErrEmptyResponse
Copy link
Contributor

Choose a reason for hiding this comment

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

I found a bug that might caused by this changes. The program may wait until the context timeout if the records are empty, and return this error:

[Info] app/dns: failed to lookup ip for domain api.twitter.com at server DOH//9.9.9.9 > context deadline exceeded
[Info] proxy/dns: ip query > app/dns: returning nil for domain api.twitter.com > multierr: context deadline exceeded |

c.c. @Loyalsoldier

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, that's my mistake

xiaokangwang added a commit that referenced this pull request Sep 4, 2021
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.

None yet

4 participants