- Timestamp:
- 2006-07-11T09:28:44Z (18 years ago)
- Branches:
- master
- Children:
- 6398094
- Parents:
- a93e3c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
ra93e3c8 rb0a33a5 46 46 char buf[128]; 47 47 #ifdef IPV6 48 struct sockaddr_in6 sock[1]; 49 #else 48 struct sockaddr_in6 sock6[1]; 49 unsigned int i6; 50 #endif 50 51 struct sockaddr_in sock[1]; 51 #endif52 52 53 53 irc = g_new0( irc_t, 1 ); … … 69 69 70 70 i = sizeof( *sock ); 71 #ifdef IPV6 72 i6 = sizeof( *sock6 ); 73 #endif 71 74 72 75 if( global.conf->hostname ) 73 76 irc->myhost = g_strdup( global.conf->hostname ); 74 77 #ifdef IPV6 75 else if( getsockname( irc->fd, (struct sockaddr*) sock , &i ) == 0 && sock->sin6_family == AF_INETx)76 { 77 if( ( peer = gethostbyaddr( (char*) &sock ->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx) ) )78 else if( getsockname( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 ) 79 { 80 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) 78 81 irc->myhost = g_strdup( peer->h_name ); 79 else if( inet_ntop( AF_INET x, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )82 else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 80 83 irc->myhost = g_strdup( ipv6_unwrap( buf ) ); 81 84 } 82 #e lse83 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET x)84 { 85 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET x) ) )85 #endif 86 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) 87 { 88 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) 86 89 irc->myhost = g_strdup( peer->h_name ); 87 else if( inet_ntop( AF_INET x, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )90 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 88 91 irc->myhost = g_strdup( buf ); 89 92 } 90 #endif91 93 92 94 i = sizeof( *sock ); 93 95 #ifdef IPV6 94 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) 95 { 96 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) 96 i6 = sizeof( *sock6 ); 97 if( getpeername( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 ) 98 { 99 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) 97 100 irc->host = g_strdup( peer->h_name ); 98 else if( inet_ntop( AF_INET x, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )101 else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 99 102 irc->host = g_strdup( ipv6_unwrap( buf ) ); 100 103 } 101 #else 102 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) 103 { 104 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) 104 else 105 #endif 106 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) 107 { 108 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) 105 109 irc->host = g_strdup( peer->h_name ); 106 else if( inet_ntop( AF_INET x, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )110 else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 107 111 irc->host = g_strdup( buf ); 108 112 } 109 #endif110 113 111 114 /* Rare, but possible. */
Note: See TracChangeset
for help on using the changeset viewer.