Forum: Ruby resolv.rb and IPv6 nameservers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
519a4d4a2a70c0c6ad0447575d71d4cc?d=identicon&s=25 Stephan Maka (Guest)
on 2006-04-23 21:27
(Received via mailing list)
Hello folks,

UDPSocket requires address family given on initialization, so it's not
possible to create an UDPSocket and *then* decide, to which hosts to
send packets to.

That's a problem for Ruby's resolver if you've got AF_INET6 nameservers
in your /etc/resolv.conf. The following very dirty hack chooses AF_INET6
for UDPSocket, if the nameserver's address contains colons (:).

--- /usr/local/lib/ruby/1.8/resolv.rb   Mon Feb  7 16:24:09 2005
+++ resolv2.rb  Sun Apr 23 20:53:17 2006
@@ -621,7 +621,7 @@
           super()
           @host = host
           @port = port
-          @sock = UDPSocket.new
+          @sock = UDPSocket.new(host.index(':') ? Socket::AF_INET6 :
Socket::AF_INET)
           @sock.connect(host, port)
           @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
           @id = -1


Any suggestions?

Stephan.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-04-24 20:28
(Received via mailing list)
On Apr 23, 2006, at 12:24 PM, Stephan Maka wrote:

> for UDPSocket, if the nameserver's address contains colons (:).
>            @sock.connect(host, port)
>            @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
>            @id = -1
>
>
> Any suggestions?

Send this patch to ruby-core or the maintainer (I think Akira Tanaka).

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
This topic is locked and can not be replied to.