aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/irc.c b/irc.c
index 1a1f511e..0bebf9b0 100644
--- a/irc.c
+++ b/irc.c
@@ -65,26 +65,38 @@ irc_t *irc_new( int fd )
irc->channel = g_strdup( ROOT_CHAN );
if( global.conf->hostname )
+ {
irc->myhost = g_strdup( global.conf->hostname );
+ }
else if( getsockname( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )
{
- irc->myhost = g_new0( char, NI_MAXHOST );
+ char buf[NI_MAXHOST+1];
- if (getnameinfo( (struct sockaddr *) &sock, socklen, irc->myhost,
- NI_MAXHOST, NULL, -1, 0) ) {
+ if( getnameinfo( (struct sockaddr *) &sock, socklen, buf,
+ NI_MAXHOST, NULL, -1, 0 ) == 0 )
+ {
+ irc->myhost = g_strdup( ipv6_unwrap( buf ) );
+ }
+ else
+ {
/* Rare, but possible. */
- strncpy( irc->myhost, "localhost.", NI_MAXHOST );
+ strncpy( irc->myhost, "localhost.localdomain", NI_MAXHOST );
}
}
if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 )
{
- irc->host = g_new0( char, NI_MAXHOST );
+ char buf[NI_MAXHOST+1];
- if ( getnameinfo( (struct sockaddr *)&sock, socklen, irc->host,
- NI_MAXHOST, NULL, -1, 0 ) ) {
+ if( getnameinfo( (struct sockaddr *)&sock, socklen, buf,
+ NI_MAXHOST, NULL, -1, 0 ) == 0 )
+ {
+ irc->host = g_strdup( ipv6_unwrap( buf ) );
+ }
+ else
+ {
/* Rare, but possible. */
- strncpy( irc->myhost, "localhost.", NI_MAXHOST );
+ strncpy( irc->host, "localhost.localdomain", NI_MAXHOST );
}
}
@@ -713,7 +725,7 @@ void irc_login( irc_t *irc )
u->online = 1;
irc_spawn( irc, u );
- irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQ's are answered there." );
+ irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there." );
if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );