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

Add compatibility for Ipv6 address #138

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

koolok
Copy link

@koolok koolok commented Apr 24, 2018

Fixes: #137

Currently the library does not support Ipv6 as host adress. To make it compatible with Ipv6 I added a function that check if host is Ipv6 and if the address is Ipv6 we can connect to Ipv6 socket otherwise we can fallback to Ipv4 socket.

@arcivanov
Copy link
Member

This doesn't work which is indicated by the build not passing, obviously.
IPv6 support doesn't just include IPv6 address string, but also support for AAAA records of a hostname.

fluent/sender.py Outdated
try :
socket.inet_pton(socket.AF_INET6, self.host)
return True
except :
Copy link
Member

@arcivanov arcivanov Apr 24, 2018

Choose a reason for hiding this comment

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

  1. PEP8 issue. Formatting all over the place. Bare except is generally frowned upon as it intercepts SystemExit and KeyboardInterrupt.

fluent/sender.py Outdated
socket.inet_aton(self.host)
return False
except Exception as e:
raise e
Copy link
Member

Choose a reason for hiding this comment

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

So what if host is FQDN???

valentin benozillo added 2 commits April 25, 2018 09:00
PIP8 ok
w to check if the host is IPv6, work with domain name�OC
@koolok
Copy link
Author

koolok commented Apr 25, 2018

@arcivanov I tried to check if the host use IPv6, even if the host is FQDN by using socket.getaddrinfo.
But the tests are still failing so can you please explain your comment #138 (review)

@koolok
Copy link
Author

koolok commented May 2, 2018

@arcivanov Can you please have a look on the changes and tell me whats exactly is wrong with the logic. Actualy I need this feature, any help will be appreciated.

fluent/sender.py Outdated
@@ -122,6 +122,13 @@ def close(self):
self._close()
self.pendings = None

def _is_ipv6_host(self):
try:
socket.getaddrinfo(self.host, None, socket.AF_INET6)
Copy link
Member

Choose a reason for hiding this comment

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

This will result in host that has AAAA records to prefer AF_INET6 even if AF_INET IPv4 addresses are available. This is not the current behavior and will potentially break tons of stuff for people who are not expecting this behavior.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 99.196% when pulling edebe05 on koolok:ipv6 into 7389fb6 on fluent:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 99.196% when pulling edebe05 on koolok:ipv6 into 7389fb6 on fluent:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 99.196% when pulling edebe05 on koolok:ipv6 into 7389fb6 on fluent:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 99.196% when pulling edebe05 on koolok:ipv6 into 7389fb6 on fluent:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 99.196% when pulling edebe05 on koolok:ipv6 into 7389fb6 on fluent:master.

@arcivanov
Copy link
Member

arcivanov commented May 3, 2018

Please write the unit tests to ensure both paths are covered and I'll merge this.

https://coveralls.io/builds/16815534/source?filename=fluent%2Fsender.py#L129

@ananalaghbar
Copy link

Hi Guys, when you are going to merge this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot connect to Ipv6.
4 participants