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.
Stephan M. (Guest)
on 2006-04-23 23: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.
Eric H. (Guest)
on 2006-04-24 22:28
(Received via mailing list)
On Apr 23, 2006, at 12:24 PM, Stephan M. 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 T.).

--
Eric H. - removed_email_address@domain.invalid - 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.