getaddrinfo(): when providing hints, make sure we use addrconfig/v4mapped.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 22 Oct 2016 11:41:26 +0000 (09:41 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 22 Oct 2016 11:46:43 +0000 (09:46 -0200)
if no hints were specified, getaddrinfo() will assume ai_flags as
AI_ADDRCONFIG | AI_V4MAPPED, which only reports useful results based
on what system supports. For instance AI_ADDRCONFIG will only return
IPv4 if IPv4 address exists, likewise IPv6 will only be returned if
IPv6 address is configured, avoiding these to be tried and error for
most local networks where such address could not be used. AI_V4MAPPED
will map IPv4 address over IPv6 if no IPv4 was found.

src/lib/ecore_con/ecore_con.c
src/lib/ecore_con/efl_net_server_tcp.c
src/lib/ecore_con/efl_net_server_udp.c

index 3c90af1..7c057b3 100644 (file)
@@ -3546,6 +3546,7 @@ _efl_net_ip_resolve_and_connect(const char *host, const char *port, int type, in
      .ai_socktype = type,
      .ai_protocol = protocol,
      .ai_family = AF_UNSPEC,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
    Eina_Error ret = EFL_NET_DIALER_ERROR_COULDNT_CONNECT;
    int r;
@@ -3732,6 +3733,7 @@ _efl_net_ip_connect_async_run_socks4(Efl_Net_Ip_Connect_Async_Data *d, const cha
      .ai_socktype = d->type,
      .ai_protocol = d->protocol,
      .ai_family = AF_INET,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
    int r;
 
@@ -3819,6 +3821,7 @@ _efl_net_ip_connect_async_run_socks4a(Efl_Net_Ip_Connect_Async_Data *d, const ch
      .ai_socktype = d->type,
      .ai_protocol = d->protocol,
      .ai_family = AF_INET,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
    int r;
 
@@ -4321,6 +4324,7 @@ _efl_net_ip_connect_async_run_socks5(Efl_Net_Ip_Connect_Async_Data *d, const cha
      .ai_socktype = d->type,
      .ai_protocol = d->protocol,
      .ai_family = AF_UNSPEC,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
    Efl_Net_Socks5_Request_Command cmd;
    int r;
@@ -4466,6 +4470,7 @@ _efl_net_ip_connect_async_run_socks5h(Efl_Net_Ip_Connect_Async_Data *d, const ch
                          .ai_socktype = d->type,
                          .ai_protocol = d->protocol,
                          .ai_family = AF_UNSPEC,
+                         .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
                        };
 
                        if (strchr(host, ':')) hints.ai_family = AF_INET6;
index cdf751f..72be31c 100644 (file)
@@ -160,6 +160,7 @@ _efl_net_server_tcp_efl_net_server_serve(Eo *o, Efl_Net_Server_Tcp_Data *pd, con
      .ai_socktype = SOCK_STREAM,
      .ai_protocol = IPPROTO_TCP,
      .ai_family = AF_UNSPEC,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINVAL);
index bc324bc..f5d79fb 100644 (file)
@@ -164,6 +164,7 @@ _efl_net_server_udp_efl_net_server_serve(Eo *o, Efl_Net_Server_Udp_Data *pd, con
      .ai_socktype = SOCK_DGRAM,
      .ai_protocol = IPPROTO_UDP,
      .ai_family = AF_UNSPEC,
+     .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED,
    };
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINVAL);