Skip to content

Querying via TCP broken #11

Description

@clue

This lib implements communication via UDP and TCP, however the TCP implementation is broken in several ways:

  • Messages sent over TCP (both directions) are to be prefixed by the message length, as per RFC 1035 section 4.2.2, here
  • Messages can be chunked and have to be reassembled based on the length prefix, here
  • Uses blocking stream_socket_client() call to connect to the DNS server, here
  • Uses Connection from the react/socket (server!) component, should use react/socket-client, here

Looks like some of these points are currently being addressed as part of #8.

Activity

  1. clue commented on Oct 23, 2014

    @clue
    MemberAuthor

    Sorry, forgot to mention: As per RFC 5966 this library prefers UDP over TCP. TCP is only used as a fallback if either the query or the answer message do not fit into a single UDP datagram (512 bytes max).

    This means that this issue does not apply to most queries. However, this can easily be reproduced by using xip.io to query an arbitrary long domain name like:

    $resolver->resolve('aaaaa.bbbb....zzzzz.xip.io');
    
  2. attockonian commented on Oct 31, 2014

    @attockonian

    @clue,

    Sorry, forgot to mention: As per RFC 5966 this library prefers UDP over TCP. TCP is only used as a fallback if either the query or the answer message do not fit into a single UDP datagram (512 bytes max).

    Doesn't this & that already take care of it?

  3. clue commented on Nov 15, 2014

    @clue
    MemberAuthor

    Doesn't this & that already take care of it?

    I believe you mean this and this? If so, I think we might have a slight misunderstanding :)

    RFC 5966 demands that DNS implementations MUST support both UDP and TCP transports.
    This is in fact implemented in this library as you rightfully pointed out.

    This library prefers UDP over TCP because it has less overhead and is therefor significantly faster.

    However, due to some smaller issues listed in my initial post, the TCP implementation is completely broken and in fact completely without function.

    Because this library prefers UDP over TCP, you might not notice this in normal operation. TCP is only used as a fallback if either the query or response message do not fit in a single 512 byte datagram. This can easily be reproduced as per my second post.

  4. attockonian commented on Nov 19, 2014

    @attockonian

    @clue okay I see what you are saying about UDP preference and TCP fallback.

  5. modified the milestone: on Feb 24, 2016
  6. self-assigned this
    on Feb 12, 2017
  7. modified the milestones: , v0.4.6 on Feb 13, 2017
  8. modified the milestones: v0.4.7, v0.4.6 on Mar 10, 2017
  9. modified the milestones: v0.4.8, v0.4.7 on Mar 30, 2017
  10. modified the milestones: v0.4.9, v0.4.8 on Apr 16, 2017
  11. modified the milestones: v0.4.10, v0.4.9 on May 1, 2017
  12. kelunik commented on Jun 29, 2017

    @kelunik

    @clue As domain names are limited to 255 characters you shouldn't be able to exceed the 512 bytes in a query when only querying one question at a time, right?

  13. clue commented on Jun 29, 2017

    @clue
    MemberAuthor

    @kelunik Yes and no :-)

    No, response messages tend to be larger than request messages and certain response messages are almost certainly guaranteed to require a TCP/IP transport because a UDP message would include a fragmentation flag otherwise.

    So yes, this is something that many people likely won't even notice, because normal A messages usually fit into a single UDP message.

    If a response message is received over UDP and includes a fragmentation flag, we try to retry the corresponding request over TCP/IP (which is completely broken as per this ticket).

  14. kelunik commented on Jun 29, 2017

    @kelunik

    @clue Sure, I know, I was only talking about large query requests, not about responses.

  15. modified the milestones: , v0.4.10 on Aug 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions