diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-07-14 11:34:56 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-07-14 11:34:56 +0200 | 
| commit | eda02703ff32d461105f0f3ca49264b7c91c5ba3 (patch) | |
| tree | 0bcc7bd2cd7b8e4f0c92fca9bc651288b0f5f624 /irc.c | |
| parent | 75a4b85ea060c5b63e9742ee9d1591bd618ba5c2 (diff) | |
| parent | 639809488bb4ab59a4a4f15ef2d4cd34037a68a4 (diff) | |
Merging from main.
Diffstat (limited to 'irc.c')
| -rw-r--r-- | irc.c | 45 | 
1 files changed, 26 insertions, 19 deletions
| @@ -46,10 +46,10 @@ irc_t *irc_new( int fd )  	unsigned int i;  	char buf[128];  #ifdef IPV6 -	struct sockaddr_in6 sock[1]; -#else -	struct sockaddr_in sock[1]; +	struct sockaddr_in6 sock6[1]; +	unsigned int i6;  #endif +	struct sockaddr_in sock[1];  	irc = g_new0( irc_t, 1 ); @@ -69,45 +69,48 @@ irc_t *irc_new( int fd )  	irc->channel = g_strdup( ROOT_CHAN );  	i = sizeof( *sock ); +#ifdef IPV6 +	i6 = sizeof( *sock6 ); +#endif  	if( global.conf->hostname )  		irc->myhost = g_strdup( global.conf->hostname );  #ifdef IPV6 -	else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) +	else if( getsockname( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )  	{ -		if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) +		if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )  			irc->myhost = g_strdup( peer->h_name ); -		else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) +		else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )  			irc->myhost = g_strdup( ipv6_unwrap( buf ) );  	} -#else -	else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) +#endif +	else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )  	{ -		if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) +		if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )  			irc->myhost = g_strdup( peer->h_name ); -		else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) +		else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )  			irc->myhost = g_strdup( buf );  	} -#endif  	i = sizeof( *sock );  #ifdef IPV6 -	if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) +	i6 = sizeof( *sock6 ); +	if( getpeername( irc->fd, (struct sockaddr*) sock6, &i6 ) == 0 && sock6->sin6_family == AF_INET6 )  	{ -		if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) +		if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) )  			irc->host = g_strdup( peer->h_name ); -		else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) +		else if( inet_ntop( AF_INET6, &sock6->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL )  			irc->host = g_strdup( ipv6_unwrap( buf ) );  	} -#else -	if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) +	else +#endif +	if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET )  	{ -		if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) +		if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) )  			irc->host = g_strdup( peer->h_name ); -		else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) +		else if( inet_ntop( AF_INET, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL )  			irc->host = g_strdup( buf );  	} -#endif  	/* Rare, but possible. */  	if( !irc->host ) irc->host = g_strdup( "localhost." ); @@ -620,6 +623,7 @@ void irc_names( irc_t *irc, char *channel )  	user_t *u;  	char namelist[385] = "";  	struct conversation *c = NULL; +	char *ops = set_getstr( irc, "ops" );  	/* RFCs say there is no error reply allowed on NAMES, so when the  	   channel is invalid, just give an empty reply. */ @@ -636,6 +640,9 @@ void irc_names( irc_t *irc, char *channel )  			if( u->gc && !u->away && set_getbool( &irc->set, "away_devoice" ) )  				strcat( namelist, "+" ); +			else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || +			         ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) +				strcat( namelist, "@" );  			strcat( namelist, u->nick );  			strcat( namelist, " " ); | 
