X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=8fd162b7122eee89c37ca319e8d2cafb71ebb16a;hp=06236fd43e2ab1269e91e1065efa11786da0ed40;hb=864015fa3ff42a026b90e39f73fb9d5f6eaab826;hpb=684e50f0a4d827965b61c4b9feeda403ec3c3b87 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 06236fd4..8fd162b7 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -918,6 +918,30 @@ va_dcl return ok; } /* Conn_WriteStr */ +GLOBAL char* +Conn_Password( CONN_ID Idx ) +{ + assert( Idx > NONE ); + if (My_Connections[Idx].pwd == NULL) + return (char*)"\0"; + else + return My_Connections[Idx].pwd; +} /* Conn_Password */ + +GLOBAL void +Conn_SetPassword( CONN_ID Idx, const char *Pwd ) +{ + assert( Idx > NONE ); + + if (My_Connections[Idx].pwd) + free(My_Connections[Idx].pwd); + + My_Connections[Idx].pwd = strdup(Pwd); + if (My_Connections[Idx].pwd == NULL) { + Log(LOG_EMERG, "Can't allocate memory! [Conn_SetPassword]"); + exit(1); + } +} /* Conn_SetPassword */ /** * Append Data to the outbound write buffer of a connection. @@ -1146,6 +1170,8 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie array_free(&My_Connections[Idx].rbuf); array_free(&My_Connections[Idx].wbuf); + if (My_Connections[Idx].pwd != NULL) + free(My_Connections[Idx].pwd); /* Clean up connection structure (=free it) */ Init_Conn_Struct( Idx ); @@ -1482,6 +1508,7 @@ New_Connection(int Sock) #endif (void)Conn_WriteStr(new_sock, "NOTICE AUTH :*** Looking up your hostname"); + (void)Handle_Write(new_sock); } Resolve_Addr(&My_Connections[new_sock].proc_stat, &new_addr, identsock, cb_Read_Resolver_Result); @@ -1839,10 +1866,10 @@ Check_Connections(void) if (My_Connections[i].lastping < time(NULL) - Conf_PongTimeout) { /* Timeout */ - LogDebug - ("Connection %d: Ping timeout: %d seconds.", - i, Conf_PongTimeout); - snprintf(msg, sizeof(msg), "Ping timeout: %d seconds", Conf_PongTimeout); + snprintf(msg, sizeof(msg), + "Ping timeout: %d seconds", + Conf_PongTimeout); + LogDebug("Connection %d: %s.", i, msg); Conn_Close(i, NULL, msg, true); } } else if (My_Connections[i].lastdata < @@ -2231,7 +2258,8 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) Client_SetHostname(c, readbuf); if (Conf_NoticeAuth) (void)Conn_WriteStr(i, - "NOTICE AUTH :*** Found your hostname"); + "NOTICE AUTH :*** Found your hostname: %s", + My_Connections[i].host); #ifdef IDENTAUTH ++identptr; if (*identptr) { @@ -2256,8 +2284,10 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) } if (Conf_NoticeAuth) { (void)Conn_WriteStr(i, - "NOTICE AUTH :*** Got %sident response", - *ptr ? "invalid " : ""); + "NOTICE AUTH :*** Got %sident response%s%s", + *ptr ? "invalid " : "", + *ptr ? "" : ": ", + *ptr ? "" : identptr); } } else { Log(LOG_INFO, "IDENT lookup for connection %d: no result.", i); @@ -2266,6 +2296,10 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) "NOTICE AUTH :*** No ident response"); } #endif + + if (Conf_NoticeAuth) + (void)Handle_Write(i); + Class_HandleServerBans(c); } #ifdef DEBUG