aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/irc.c b/irc.c
index fe55a02c..9feb9f4e 100644
--- a/irc.c
+++ b/irc.c
@@ -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, " " );