Changeset 1024


Ignore:
Timestamp:
Mar 1, 2007 5:28:35 PM (12 years ago)
Author:
bennylp
Message:

Fixed ticket #150: pj_gethostip() should fallback to default interface when 127.x.x.x is returned, not just 127.0.0.1 (thanks Andrey Kuprianov)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjlib/src/pj/addr_resolv_sock.c

    r1022 r1024  
    6060    const pj_str_t *hostname = pj_gethostname(); 
    6161    struct pj_hostent he; 
    62     pj_str_t cp; 
    63     pj_in_addr loopip; 
    6462    pj_status_t status; 
    6563 
    66     cp = pj_str("127.0.0.1"); 
    67     loopip = pj_inet_addr(&cp); 
    6864 
    6965#ifdef _MSC_VER 
     
    7975 
    8076 
    81     /* If we end up with 127.0.0.1, resolve the IP by getting the default 
     77    /* If we end up with 127.x.x.x, resolve the IP by getting the default 
    8278     * interface to connect to some public host. 
    8379     */ 
    84     if (status != PJ_SUCCESS || addr->s_addr == loopip.s_addr) { 
     80    if (status != PJ_SUCCESS || (pj_ntohl(addr->s_addr) >> 24)==127) { 
    8581        pj_sock_t fd; 
     82        pj_str_t cp; 
    8683        pj_sockaddr_in a; 
    8784        int len; 
Note: See TracChangeset for help on using the changeset viewer.