close
Skip to content

IPv6 #42

@Rotario

Description

@Rotario

Hi - I can't seem to get IPv6 working.
Something changed when I updated my gems (not ruby) and now the URI Parsing isn't working with the bracket notation
If I do

Net::HTTP.new('::', 8080).start
=> #<Net::HTTP :::8080 open=true>

The socket is opened and the connection works to an XMLRPC server
If instead I do

XMLRPC::Client.new('[::]', '/RPC2', 8080).call('system.listMethods')
home/xxx/.rbenv/versions/3.1.0/lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to [::]:8080 (getaddrinfo: Name or service not known) (SocketError)
/home/xxx/.rbenv/versions/3.1.0/lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)

I get this exception, which means the [::] IPv6 ip is being interpreted as a DNS hostname (the brackets must be trimmed)

If I monkey-patch XMLRPC::Client.net_http like this to trim the brackets manually

module XMLRPC
  class Client
    def net_http(host, port, proxy_host, proxy_port)
      Net::HTTP.new host.tr('[]', ''), port, proxy_host, proxy_port
    end
  end
end

Then the Net::HTTP instance is created correctly and the connection can be opened

XMLRPC::Client.new('[::]', '/path', 8080)
=> 
#<XMLRPC::Client:0x00007fd9e1098a68
 @auth=nil,
 @cookie=nil,
 @create=nil,
 @host="[::]",
 @http=#<Net::HTTP [::]:8080 open=false>,
 @http_header_extra=nil,
 @http_last_response=nil,
 @parser=nil,
 @password=nil,
 @path="/path",
 @port=8080,
 @proxy_host=nil,
 @proxy_port=nil,
 @timeout=30,
 @use_ssl=false,
 @user=nil>

But then when I try to call the client

XMLRPC::Client.new('[::]', '/path', 8080).call('system.listMethods')
/home/xxxx/.rbenv/versions/3.1.0/lib/ruby/3.1.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): "http://::/path" (URI::InvalidURIError)

I get an Invalid URI Error.

I can't seem to find the call point where a URI is built in call yet. Will try to monkey patch that to see if it works temporarily.

I have a feeling this is related to the age old bug here https://bugs.ruby-lang.org/issues/3788

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions