-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net: resolver add unexpected bytes to udp packet when wrapping the net.Conn #49750
Comments
In 3 the dialer will always use udp regardless of the network requested. This may cause a problem if the dns resolver was trying to to use tcp because the udp response was truncated |
@davecheney Thanks for advice! I would use |
You must implement Lines 176 to 188 in b65e259
|
Do we want to change the logic and use the network (variable from the loop) instead of checking if it implements net.PacketConn (simple if network == "udp")? Lines 166 to 172 in b65e259
|
Thanks! @mateusz834 I test again with the Anyway, I'd close this issue as it is resolved. Thanks again! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I tested in latest golang docker.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
1. Start a simple udp echo server in localhost
2. Run a dns resolver client, but redirect the dns udp packets to the echo server
3. Wrap the net.Conn and run again.
4. Test wrapping net.Conn only, which means the problem is not come from the struct wrapping.
What did you expect to see?
Both 2 and 3 send valid dns packet to echo server or dns server.
For 4, echo server receives same data as I sent, which is expected.
What did you see instead?
The data sent by 2 is a valid dns packet. If I change destination to
8.8.8.8:53
, I could get the dns result.The data sent by 3 is not a valid dns packet. If I change destination to
8.8.8.8:53
, I can't get the dns result.The following is the data received from echo server, I found the invalid data would always have two more bytes in the front of the packet. These two bytes seems to be the length of the following bytes whenever I change the hostname.
The first 4 lines is valid dns packet, length 58.
The last 4 line is invalid dns packet, length 60, while 003a is 58 in OCT.
The text was updated successfully, but these errors were encountered: