-
Notifications
You must be signed in to change notification settings - Fork 305
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
Add ipv6 support for dogstatsd #791
Conversation
Keyword arguments not supported on py2.7
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.
Left a small remark, approved for a future merge as the rest looks good to me!
sock = None | ||
try: | ||
sock = socket.socket(af, ty, proto) | ||
sock.connect(addr) |
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.
Since your change, are you sure it's OK to call the settimeout
after the call to connect
? Could be for UDP but might be worth preserving the old behavior: https://docs.python.org/3/library/socket.html#timeouts-and-the-connect-method
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'm pretty sure socket timeout doesn't make any difference for udp sockets, but just for symmetry I updated the code to have the order same between udp and uds.
This makes no difference with udp sockets, but do it anyway for symmetry and ease of maintenace.
What does this PR do?
Add IPv6 support for hostnames and literal addresses.
Description of the Change
Call
getaddrinfo
to parse and resolve an internet address before creating the socket. Try in a loop until one address succeeds.For backwards compatibility, prefer ipv4 addresses: ipv4-only agent should still work even if hostname (e.g.
localhost
) resolves to both ipv4 and ipv6 address and ipv6 is preferred by the OS. This also matches behavior of Golang.Alternate Designs
Possible Drawbacks
Address order specified in
gai.conf
is ignored, which may lead to inconsistencies with other applications.Verification Process
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/
label attached. If applicable it should have thebackward-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.