Follow-up Comment #5, bug #16751 (project freeciv):

> I'd say that bug is not in Freeciv, but in the fact that /etc/hosts makes
"localhost" to resolve as "::1" even though IPv6 is disabled in the system.

I guess that this is bug in Freeciv. You can have "localhost" resolve to
"::1", whether IPv6 is enabled or disabled.

In general, names can resolve to IPv6 addresses, whether or not the machine
has IPv6. For example, I have IPv4-only access to internet, but DNS assigns
IPv6 addresses to many names. I am not required to change the entire internet
DNS to remove all IPv6 addresses. For example,



~ $ host www.kame.net
www.kame.net is an alias for orange.kame.net.
orange.kame.net has address 203.178.141.194
orange.kame.net has IPv6 address 2001:200:dff:fff1:216:3eff:feb1:44d7



I can visit http://www.kame.net by its IPv4 address, without removing its
IPv6 address from DNS.

The bug in Freeciv might (or might not) be here in client/clinet.c:



  if (!net_lookup_service(hostname, port, &server_addr, FALSE)) {
    (void) mystrlcpy(errbuf, _("Failed looking up host."), errbufsize);
    return -1;
  }



But if hostname has IPv6 address, and net_lookup_service() 4th argument is
FALSE, then this will only find the IPv6 address, never the IPv4 address.
This is broken, because clients on IPv4-only connections cannot connect to a
server that has both IPv4 and IPv6 in DNS.

My patch for bug #15559 changes client/clinet.c:



  if (!net_lookup_service(hostname, port, &names[0], FALSE)) {
    (void) mystrlcpy(errbuf, _("Failed looking up host."), errbufsize);
    return -1;
  }
  name_count = 1;
#ifdef IPV6_SUPPORT
  if (names[0].saddr.sa_family == AF_INET6) {
    /* net_lookup_service() prefers IPv6 address.
     * Check if there is also IPv4 address.
     * TODO: This would be easier using getaddrinfo() */
    if (net_lookup_service(hostname, port,
                           &names[1], TRUE /* force IPv4 */)) {
      name_count = 2;
    }
  }
#endif



So it finds both IPv4 and IPv6 addresses. This was part of my attempt to fix
bug #15559 (Client can't connect to its locally started server). This allowed
my client to reach an IPv4-only server (./ser -b 0.0.0.0) at "localhost".

I suspect that the original submitter has Linux kernel without AF_INET6.
Freeciv server handles EAFNOSUPPORT from socket() and switches to IPv4.
Freeciv client fails to connect to ::1 but also fails to switch to 127.0.0.1.

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?16751>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to