-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
DNS - implementing TCP #486
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
} | ||
} | ||
|
||
payload := make([]byte, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preferred way to declare and empty slice is var payload []byte
because it avoids an allocation if the slice is never appended.
@McStork Thanks for the great work! I left a few comments (all minor). |
Thanks for the review. Will update soon. |
544a0b7
to
93152d4
Compare
Gaps are better managed now. However I wounder about the I will have to read more of the |
b5d1816
to
9318cb4
Compare
@andrewkroh As you suggested in the review, I added Notes for when a response cannot be decoded in a TCP stream (Fin and Gap). That's a partial implementation of the TODO list point 'Publish a message when packets are received that cannot be decoded.'.
@andrewkroh Do you want to do more review ? Can we expect a merge soon ? =) |
1031d30
to
4a8d41d
Compare
LGTM, yes, I think we can merge it today, but I'd like to wait for @andrewkroh to have one final look. |
* Implement DNS over TCP * Publish Notes when a response fails to decode in Gap and Fin
0194483
to
e268f01
Compare
|
||
var payload []byte | ||
|
||
// Offset is critical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the reason for the two byte offset. "The message is prefixed with a two byte length field which gives the message length, excluding the two byte length field." - RFC 1035 - 4.2.2
This code should use the length field to short-circuit any processing. There is no need to attempt to decode the data when number of bytes is less than the length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it will print a debug message "Packet's data is null."
I built Packetbeat from your branch and ran some DNS queries over TCP ( The events have |
Thanks, I will look into it |
I couldn't reproduce it. This message is only displayed if you get a Fin or Get with unvalid response DNS data. I will keep trying ;) |
* return from Parse() if the packet length is <= Offset * check if streams nil in publishDecodeFailureNotes()
d60694c
to
bef7e71
Compare
Try the attached PCAP which contains a single DNS query for google.com over TCP. It should reproduce the
|
It's good that you could make a split TCP query without DNSSEC. |
The offset was not managed how it should have been: * TCP decode Offset is now managed in the function decodeDnsData() * Add a unit test calling the Parse() method on a split query Also: * remove assignements and use pointers to alter DnsStream objects in Parse()
7bb7369
to
7b8861b
Compare
return priv | ||
} | ||
if dataLength <= DecodeOffset { | ||
logp.Debug("dns", EmptyMsg+" addresses %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message is not empty, but it is incomplete and the code will wait for more bytes to complete the message. I think the other protocols log messages for a similar case so maybe take a look at those messages.
@McStork Thanks for you contribution! I left a few minor comments about possible enhancements. They are not critical to the feature so I am merging now. |
@andrewkroh Thank you very much for the reviews. I will open a new PR to address your comments. |
|
||
payload := pkt.Payload | ||
|
||
stream := &priv.Data[dir] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, pointer of pointer. I'd rather byte the bullet and do the assignment in line 753 instead of having to type (*stream) all over the place.
Check redis code for some cleaned-up solution (using pointers for connection) for cast and append (using streambuf.Buffer though). https://github.com/elastic/beats/blob/master/packetbeat/protos/redis/redis.go#L107
the dnsPrivateData data type is actually the connection context. Consider naming it so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do that 😃
#386
Thanks @andrewkroh for the rebase.