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

DNS over TCP clean-up and improvements #554

Merged
merged 2 commits into from
Jan 6, 2016

Conversation

McStork
Copy link
Contributor

@McStork McStork commented Dec 17, 2015

Refactor, clean-up and address reviews of the first DNS over TCP PR

  • Use RFC 1035 'bytes offset' to decode DNS over TCP payloads
  • Correct Streams management
  • Improve error management (for Debug and published Notes)
  • Tests improvement
  • Split files of package dns

Minor changes:

  • Change the name of dnsPrivateData to dnsConnectionData to reflect
    the naming used in other applayers
  • Split the Parse() method in multiple functions to comply more with the code convention
    used in other applayers implementation
  • Remove a PCAP file from the previous and first DNS over TCP pull request
  • Introduce a README.md file

@elasticsearch-release
Copy link

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'.

if dataLength <= DecodeOffset {
logp.Debug("dns", EmptyMsg+" addresses %s",
Copy link

Choose a reason for hiding this comment

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

move dataLength check after if-else?

@McStork
Copy link
Contributor Author

McStork commented Dec 17, 2015

Will do more code refactoring

@McStork McStork changed the title Address reviews of PR #486 DNS over TCP clean-up and improvements Dec 21, 2015
@McStork McStork force-pushed the clean-dns-tcp branch 4 times, most recently from 41bd034 to b820a9e Compare January 4, 2016 15:16
@McStork
Copy link
Contributor Author

McStork commented Jan 5, 2016

Happy new year! May 2016 bring even more users to the Beat shippers 😃 .

I finished with all the cleaning and fixes. @andrewkroh , your last comment went missing from GitHub 😞 but it isn't lost since this PR addresses it.

The PR corrects the Stream management and improves the debug messages and the published error Notes. It is ready for review.

* Use RFC 1035 'bytes offset' to decode DNS over TCP payloads
* Correct Streams management
* Improve error management (for Debug and published Notes)
* Tests improvement
* Split files of ```package dns```

Minor changes:
* Change the name of dnsPrivateData to dnsConnectionData to reflect
the naming used in other applayers
* Split the ```Parse()``` method in multiple functions to comply more with the code convention
 used in other applayers implementation
* Remove a PCAP file from the previous and first DNS over TCP pull request
* Introduce a README.md file
@andrewkroh
Copy link
Member

Thanks @McStork, I will review this soon.

trans.Notes = append(trans.Notes, OrphanedResponseMsg)
logp.Debug("dns", OrphanedResponseMsg+" %s", tuple)
trans.Notes = append(trans.Notes, OrphanedResponse.Error())
logp.Debug("dns", OrphanedResponse.Error()+" %s", tuple)
Copy link

Choose a reason for hiding this comment

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

try to not pass a generated format string as first parameter to printf like functions. Better:

debug("%s %s", OrphanedResponse, tuple)

where

var debug = logp.MakeDebug("dns")

@urso
Copy link

urso commented Jan 5, 2016

all in all LGTM

* Use printf format in all debug messages
* Rename err in handleDecode
* Remove a useless pointer assignement and move another one into a if statement
@andrewkroh
Copy link
Member

I like all the test cases you added. 👍

}

// Checks that PrepareNewMessage and Parse can manage two messages sharing one packet on the same stream
// It typically happens when a SOA is followed by AXFR
Copy link
Member

Choose a reason for hiding this comment

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

This comment misled me slightly. I thought it was going to be a test case for two DNS requests with unique IDs like you would see with a SOA and a AXFR being sent over one connection. That is a case that this package does not handle (yet).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewkroh Yes, the comment can be misleading. It would be better with two requests with unique ID.
But still, I think the test does the job with a short amount of lines of code. The test shows that two requests that share one connection (and one packet during the connection) will get parsed and create transactions. Right?

@andrewkroh
Copy link
Member

LGTM

andrewkroh added a commit that referenced this pull request Jan 6, 2016
DNS over TCP clean-up and improvements
@andrewkroh andrewkroh merged commit 8840d6c into elastic:master Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants