Changeset 5098:49d6eb21d70e in roaraudio for libroar


Ignore:
Timestamp:
07/23/11 13:27:26 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

warn about numerical hostnames for IP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/socket.c

    r4939 r5098  
    535535 char port_as_string[32]; 
    536536#endif 
     537#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) 
     538 int is_numerical = 1; 
     539 const char * numptr; 
     540#endif 
    537541 
    538542 ROAR_DBG("roar_socket_open(mode=%i, type=%i, host='%s', port=%i) = ?", mode, type, host, port); 
     
    620624 
    621625  ROAR_DBG("roar_socket_open(*): type=INET|INET6, host='%s', port=%i", host, port); 
     626 
     627  if ( !!strcmp(host, "0.0.0.0") ) { 
     628   for (numptr = host; is_numerical && *numptr != 0; numptr++) 
     629    if ( ! ((*numptr >= '0' && *numptr <= '9') || *numptr == '.')  ) 
     630     is_numerical = 0; 
     631 
     632   if ( is_numerical ) { 
     633    ROAR_WARN("roar_socket_open(*): Hostname \"%s\" is numerical. Do not use IP addresses directly. Use Hostnames.", host); 
     634   } 
     635  } 
    622636 
    623637#ifdef ROAR_HAVE_GETADDRINFO 
Note: See TracChangeset for help on using the changeset viewer.