Changeset eda0270 for irc.c


Ignore:
Timestamp:
2006-07-14T09:34:56Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
00a5270
Parents:
75a4b85 (diff), 6398094 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging from main.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r75a4b85 reda0270  
    4747        char buf[128];
    4848#ifdef IPV6
    49         struct sockaddr_in6 sock[1];
    50 #else
     49        struct sockaddr_in6 sock6[1];
     50        unsigned int i6;
     51#endif
    5152        struct sockaddr_in sock[1];
    52 #endif
    5353       
    5454        irc = g_new0( irc_t, 1 );
     
    7070       
    7171        i = sizeof( *sock );
     72#ifdef IPV6
     73        i6 = sizeof( *sock6 );
     74#endif
    7275       
    7376        if( global.conf->hostname )
    7477                irc->myhost = g_strdup( global.conf->hostname );
    7578#ifdef IPV6
    76         else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx )
    77         {
    78                 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) )
     79        else if( getsockname( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )
     80        {
     81                if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )
    7982                        irc->myhost = g_strdup( peer->h_name );
    80                 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
     83                else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
    8184                        irc->myhost = g_strdup( ipv6_unwrap( buf ) );
    8285        }
    83 #else
    84         else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx )
    85         {
    86                 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) )
     86#endif
     87        else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )
     88        {
     89                if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )
    8790                        irc->myhost = g_strdup( peer->h_name );
    88                 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
     91                else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
    8992                        irc->myhost = g_strdup( buf );
    9093        }
    91 #endif
    9294       
    9395        i = sizeof( *sock );
    9496#ifdef IPV6
    95         if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx )
    96         {
    97                 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) )
     97        i6 = sizeof( *sock6 );
     98        if( getpeername( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )
     99        {
     100                if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )
    98101                        irc->host = g_strdup( peer->h_name );
    99                 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
     102                else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )
    100103                        irc->host = g_strdup( ipv6_unwrap( buf ) );
    101104        }
    102 #else
    103         if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx )
    104         {
    105                 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) )
     105        else
     106#endif
     107        if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )
     108        {
     109                if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )
    106110                        irc->host = g_strdup( peer->h_name );
    107                 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
     111                else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )
    108112                        irc->host = g_strdup( buf );
    109113        }
    110 #endif
    111114       
    112115        /* Rare, but possible. */
     
    621624        char namelist[385] = "";
    622625        struct conversation *c = NULL;
     626        char *ops = set_getstr( irc, "ops" );
    623627       
    624628        /* RFCs say there is no error reply allowed on NAMES, so when the
     
    637641                        if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) )
    638642                                strcat( namelist, "+" );
     643                        else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||
     644                                 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )
     645                                strcat( namelist, "@" );
    639646                       
    640647                        strcat( namelist, u->nick );
Note: See TracChangeset for help on using the changeset viewer.