Changeset 7435ccf
- Timestamp:
- 2007-10-18T19:03:02Z (17 years ago)
- Branches:
- master
- Children:
- 2231302
- Parents:
- e9b755e
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
re9b755e r7435ccf 45 45 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 46 46 47 memset( &hints, 0, sizeof(hints));47 memset( &hints, 0, sizeof( hints ) ); 48 48 hints.ai_family = PF_UNSPEC; 49 49 hints.ai_socktype = SOCK_STREAM; 50 50 hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; 51 51 52 i = getaddrinfo( global.conf->iface, global.conf->port, &hints,53 &addrinfo_bind );54 if ( i) {52 i = getaddrinfo( global.conf->iface, global.conf->port, &hints, 53 &addrinfo_bind ); 54 if ( i ) { 55 55 log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s", 56 56 global.conf->iface, gai_strerror(i) ); … … 60 60 global.listen_socket = -1; 61 61 62 for ( res = addrinfo_bind; res; res = res->ai_next) {63 global.listen_socket = socket( res->ai_family, res->ai_socktype,64 res->ai_protocol);65 if ( global.listen_socket < 0)62 for ( res = addrinfo_bind; res; res = res->ai_next ) { 63 global.listen_socket = socket( res->ai_family, res->ai_socktype, 64 res->ai_protocol ); 65 if ( global.listen_socket < 0 ) 66 66 continue; 67 67 … … 71 71 sizeof( i ) ); 72 72 73 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );73 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen ); 74 74 if( i == -1 ) 75 75 { … … 81 81 } 82 82 83 freeaddrinfo( addrinfo_bind);83 freeaddrinfo( addrinfo_bind ); 84 84 85 85 i = listen( global.listen_socket, 10 ); -
irc.c
re9b755e r7435ccf 46 46 irc_t *irc; 47 47 struct sockaddr_storage sock; 48 socklen_t socklen = sizeof( sock);48 socklen_t socklen = sizeof( sock ); 49 49 50 50 irc = g_new0( irc_t, 1 ); … … 67 67 if( global.conf->hostname ) 68 68 irc->myhost = g_strdup( global.conf->hostname ); 69 else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )70 { 71 irc->myhost = g_new0( char, NI_MAXHOST);72 73 if (getnameinfo( (struct sockaddr *)&sock, socklen, irc->myhost,74 NI_MAXHOST, NULL, -1, 0) ) {69 else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) 70 { 71 irc->myhost = g_new0( char, NI_MAXHOST ); 72 73 if (getnameinfo( (struct sockaddr *) &sock, socklen, irc->myhost, 74 NI_MAXHOST, NULL, -1, 0) ) { 75 75 /* Rare, but possible. */ 76 strncpy( irc->myhost, "localhost.", NI_MAXHOST);77 } 78 } 79 80 if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )81 { 82 irc->host = g_new0( char, NI_MAXHOST);83 84 if ( getnameinfo((struct sockaddr *)&sock, socklen, irc->host,85 NI_MAXHOST, NULL, -1, 0 )) {76 strncpy( irc->myhost, "localhost.", NI_MAXHOST ); 77 } 78 } 79 80 if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) 81 { 82 irc->host = g_new0( char, NI_MAXHOST ); 83 84 if ( getnameinfo( (struct sockaddr *)&sock, socklen, irc->host, 85 NI_MAXHOST, NULL, -1, 0 ) ) { 86 86 /* Rare, but possible. */ 87 strncpy( irc->myhost, "localhost.", NI_MAXHOST);87 strncpy( irc->myhost, "localhost.", NI_MAXHOST ); 88 88 } 89 89 }
Note: See TracChangeset
for help on using the changeset viewer.