Add optional IPv6 support #38

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@aw
Contributor
aw commented Mar 10, 2013

Added a 3rd argument to the StatsD initializer, a boolean which we use to specify if our host is an IPv6 address or not.

I chose to strictly specify the type since we don't want to resolve the host to determine if it's an v4 or v6 (and trust me, OS X will damage your brain when you get into that.. something about the default /etc/hosts having multiple addresses resolving for localhost, and Ruby choosing ::1 as the default for IPSocket.getaddress('localhost').. what a pain.. ANYWAYS.

Here's a first attempt at enabling it. 🌊

Usage:

$statsd = Statsd.new '::1', 9125, true
@raggi
Collaborator
raggi commented Mar 31, 2013

Maybe this could be determined by looking at the IP address instead of by a boolean?

@raggi
Collaborator
raggi commented Mar 31, 2013

e.g.

require 'ipaddr'
IPAddr.new('127.0.0.1').ipv4?

We'll need to do a resolve at socket setup time though, if it's a dns name.

@aw
Contributor
aw commented Apr 1, 2013

Why?

I don't see any advantage in trying to do guesswork on something that is already known. Not to mention the additional overhead and possible issues with yet another dependency.

@raggi
Collaborator
raggi commented Apr 2, 2013

ipaddr and resolv are in the stdlib. if someone passes a dns name, they do not know if it's ipv4 or ipv6, so I have some problems with the premise "something that is already known".

@aw
Contributor
aw commented Apr 3, 2013

You're right.

When I have time i'll look into writing an improved patch. Thanks!

@aw aw closed this Apr 3, 2013
@aw aw referenced this pull request Sep 6, 2013
Merged

Add IPv6 support #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment