commit - 5e16b6df2dbe7a953bf6c29f270221163cd517c1
commit + 544b9884f4ccab6488b6f75b5fafd68a85aa8cd7
blob - 5ad412217e98eb615927d0620e8945d8c78030de
blob + 50648c97ef81842807305cd330cd5643ed6c81a6
--- src/ngircd/client.c
+++ src/ngircd/client.c
client = New_Client_Struct( );
if( ! client ) return NULL;
- /* Initialisieren */
client->starttime = time(NULL);
client->conn_id = Idx;
client->introducer = Introducer;
if( strchr( client->modes, 'a' ))
strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
- /* Verketten */
client->next = (POINTER *)My_Clients;
My_Clients = client;
- /* Adjust counters */
Adjust_Counters( client );
return client;
GLOBAL void
Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit )
{
- /* Client entfernen. */
+ /* remove a client */
CLIENT *last, *c;
char msg[LINE_LEN];
else txt = FwdMsg;
if( ! txt ) txt = "Reason unknown.";
- /* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
+ /* netsplit message */
if( Client->type == CLIENT_SERVER ) {
strlcpy(msg, This_Server->id, sizeof (msg));
strlcat(msg, " ", sizeof (msg));
{
if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
{
- /* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
- * pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
+ /*
+ * The client that is about to be removed is a server,
+ * the client we are checking right now is a child of that
+ * server and thus has to be removed, too.
+ *
+ * Call Client_Destroy() recursively with the server as the
+ * new "object to be removed". This starts the cycle again, until
+ * all servers that are linked via the original server have been
+ * removed.
+ */
Client_Destroy( c, NULL, msg, false );
last = NULL;
c = My_Clients;
}
if( c == Client )
{
- /* Wir haben den Client gefunden: entfernen */
+ /* found the client: remove it */
if( last ) last->next = c->next;
else My_Clients = (CLIENT *)c->next;
else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
}
- /* andere Server informieren */
+ /* inform other servers */
if( ! NGIRCd_SignalQuit )
{
if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
blob - 8da62ae8b8afa5dad52ad559d52423bf02387ac8
blob + 196325eea1aa82ee6083e04d7a94a5866c22e3ad
--- src/ngircd/conn-func.c
+++ src/ngircd/conn-func.c
#include "portab.h"
-static char UNUSED id[] = "$Id: conn-func.c,v 1.12 2008/03/11 14:05:27 alex Exp $";
-
#include "imp.h"
#include <assert.h>
#include <string.h>
GLOBAL void
Conn_UpdateIdle( CONN_ID Idx )
{
- /* Idle-Timer zuruecksetzen */
-
assert( Idx > NONE );
My_Connections[Idx].lastprivmsg = time( NULL );
}
GLOBAL time_t
Conn_GetIdle( CONN_ID Idx )
{
- /* Idle-Time einer Verbindung liefern (in Sekunden) */
-
+ /* Return Idle-Timer of a connetion */
assert( Idx > NONE );
return time( NULL ) - My_Connections[Idx].lastprivmsg;
} /* Conn_GetIdle */
GLOBAL time_t
Conn_LastPing( CONN_ID Idx )
{
- /* Zeitpunkt des letzten PING liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].lastping;
} /* Conn_LastPing */
GLOBAL void
Conn_SetPenalty( CONN_ID Idx, time_t Seconds )
{
- /* Penalty-Delay fuer eine Verbindung (in Sekunden) setzen;
- * waehrend dieser Zeit wird der entsprechende Socket vom Server
- * bei Lese-Operationen komplett ignoriert. Der Delay kann mit
- * dieser Funktion nur erhoeht, nicht aber verringert werden. */
-
+ /* set Penalty-Delay for a socket.
+ * during the penalty, the socket is ignored completely, no new
+ * data is read. This function only increases the penalty, it is
+ * not possible to decrease the penalty time.
+ */
time_t t;
assert( Idx > NONE );
GLOBAL void
Conn_ClearFlags( void )
{
- /* Alle Connection auf "nicht-markiert" setzen */
-
CONN_ID i;
for( i = 0; i < Pool_Size; i++ ) My_Connections[i].flag = 0;
GLOBAL int
Conn_Flag( CONN_ID Idx )
{
- /* Ist eine Connection markiert (true) oder nicht? */
-
assert( Idx > NONE );
return My_Connections[Idx].flag;
} /* Conn_Flag */
return 0;
} /* Conn_StartTime */
-
+/**
+ * return number of bytes queued for writing
+ */
GLOBAL size_t
Conn_SendQ( CONN_ID Idx )
{
- /* Laenge der Daten im Schreibbuffer liefern */
-
assert( Idx > NONE );
#ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP )
} /* Conn_SendQ */
+/**
+ * return number of messages sent on this connection so far
+ */
GLOBAL long
Conn_SendMsg( CONN_ID Idx )
{
- /* Anzahl gesendeter Nachrichten liefern */
assert( Idx > NONE );
return My_Connections[Idx].msg_out;
} /* Conn_SendMsg */
+/**
+ * return number of (uncompressed) bytes sent
+ * on this connection so far
+ */
GLOBAL long
Conn_SendBytes( CONN_ID Idx )
{
- /* Anzahl gesendeter Bytes (unkomprimiert) liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].bytes_out;
} /* Conn_SendBytes */
+/**
+ * return number of bytes pending in read buffer
+ */
GLOBAL size_t
Conn_RecvQ( CONN_ID Idx )
{
- /* Laenge der Daten im Lesebuffer liefern */
-
assert( Idx > NONE );
#ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP )
} /* Conn_RecvQ */
+/**
+ * return number of messages received on this connection so far
+ */
GLOBAL long
Conn_RecvMsg( CONN_ID Idx )
{
- /* Anzahl empfangener Nachrichten liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].msg_in;
} /* Conn_RecvMsg */
+/**
+ * return number of (uncompressed) bytes received on this
+ * connection so far
+ */
GLOBAL long
Conn_RecvBytes( CONN_ID Idx )
{
- /* Anzahl empfangener Bytes (unkomprimiert) liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].bytes_in;
} /* Conn_RecvBytes */
blob - d77222351a686ceee60ef7b94beea035552830a1
blob + 0b9161f35f85e4fa0346053ab8ea1aeb92abfcb4
--- src/ngircd/conn-zip.c
+++ src/ngircd/conn-zip.c
* Connection compression using ZLIB
*/
-
#include "portab.h"
#define CONN_MODULE
-
#ifdef ZLIB
/* enable more zlib related debug messages: */
/* #define DEBUG_ZLIB */
-static char UNUSED id[] = "$Id: conn-zip.c,v 1.16 2007/05/17 23:34:24 alex Exp $";
-
#include "imp.h"
#include <assert.h>
#include <string.h>
GLOBAL bool
Zip_InitConn( CONN_ID Idx )
{
- /* Kompression fuer Link initialisieren */
+ /* initialize zlib compression on this link */
assert( Idx > NONE );
My_Connections[Idx].zip.in.zfree = NULL;
My_Connections[Idx].zip.in.data_type = Z_ASCII;
- if( inflateInit( &My_Connections[Idx].zip.in ) != Z_OK )
- {
- /* Fehler! */
- Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx );
+ if (inflateInit( &My_Connections[Idx].zip.in ) != Z_OK) {
+ Log(LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx);
return false;
}
My_Connections[Idx].zip.out.zfree = NULL;
My_Connections[Idx].zip.out.data_type = Z_ASCII;
- if( deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK )
- {
- /* Fehler! */
- Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx );
+ if (deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK) {
+ Log(LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx);
return false;
}
My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out;
- Log( LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx );
+ Log(LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx);
Conn_OPTION_ADD( &My_Connections[Idx], CONN_ZIP );
return true;
* Compress data in ZIP buffer and move result to the write buffer of
* the connection.
* @param Idx Connection handle.
- * @retrun true on success, false otherwise.
+ * @return true on success, false otherwise.
*/
GLOBAL bool
Zip_Flush( CONN_ID Idx )
} /* Zip_Flush */
+/**
+ * uncompress data and copy it to read buffer.
+ * Returns true if data has been unpacked or no
+ * compressed data is currently pending in the zread buffer.
+ * @param Idx Connection handle.
+ * @return true on success, false otherwise.
+ */
GLOBAL bool
Unzip_Buffer( CONN_ID Idx )
{
- /* Daten entpacken und in Lesepuffer kopieren. Bei Fehlern
- * wird false geliefert, ansonsten true. Der Fall, dass keine
- * Daten mehr zu entpacken sind, ist _kein_ Fehler! */
-
int result;
unsigned char unzipbuf[READBUFFER_LEN];
int unzipbuf_used = 0;
result = inflate( in, Z_SYNC_FLUSH );
if( result != Z_OK )
{
- Log( LOG_ALERT, "Decompression error: %s (code=%d, ni=%d, ai=%d, no=%d, ao=%d)!?", in->msg, result, in->next_in, in->avail_in, in->next_out, in->avail_out );
- Conn_Close( Idx, "Decompression error!", NULL, false );
+ Log(LOG_ALERT, "Decompression error: %s (code=%d, ni=%d, ai=%d, no=%d, ao=%d)!?", in->msg, result, in->next_in, in->avail_in, in->next_out, in->avail_out);
+ Conn_Close(Idx, "Decompression error!", NULL, false);
return false;
}
} /* Unzip_Buffer */
+/**
+ * @param Idx Connection handle.
+ * @return amount of sent (compressed) bytes
+ */
GLOBAL long
Zip_SendBytes( CONN_ID Idx )
{
- /* Anzahl gesendeter Bytes (komprimiert!) liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_out;
} /* Zip_SendBytes */
+/**
+ * @param Idx Connection handle.
+ * @return amount of received (compressed) bytes
+ */
GLOBAL long
Zip_RecvBytes( CONN_ID Idx )
{
- /* Anzahl gesendeter Bytes (komprimiert!) liefern */
-
assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_in;
} /* Zip_RecvBytes */
blob - c27cebf9a7b74301c219f03f1e10332df45f7b15
blob + eacbe5ae0fa5616a6a66528e2fefb1e8eb603f30
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
GLOBAL void
Conn_Init( void )
{
- /* Modul initialisieren: statische Strukturen "ausnullen". */
-
CONN_ID i;
/* Speicher fuer Verbindungs-Pool anfordern */
GLOBAL void
Conn_Exit( void )
{
- /* Modul abmelden: alle noch offenen Connections
- * schliessen und freigeben. */
-
CONN_ID idx;
Conn_ExitListeners();
static CONN_ID
Socket2Index( int Sock )
{
- /* zum Socket passende Connection suchen */
-
assert( Sock >= 0 );
if( Sock >= Pool_Size || My_Connections[Sock].sock != Sock ) {
- /* die Connection wurde vermutlich (wegen eines
- * Fehlers) bereits wieder abgebaut ... */
+ /* the Connection was already closed again, likely due to
+ * an error. */
LogDebug("Socket2Index: can't get connection for socket %d!", Sock);
return NONE;
}
blob - e9345217c5c353e2608d2b3f7ba62e6bdb4b60e3
blob + f57a6a190d5c0a9e57b4f0ee315e349814cc609b
--- src/ngircd/irc-info.c
+++ src/ngircd/irc-info.c
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* Ziel suchen */
+ /* find target ... */
if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
else target = Client_ThisServer( );
- /* Prefix ermitteln */
+ /* find Prefix */
if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
else prefix = Client;
if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
- /* An anderen Server weiterleiten? */
+ /* forwad message to another server? */
if( target != Client_ThisServer( ))
{
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
- /* forwarden */
+ /* forward */
IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
return CONNECTED;
}
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Server-Mask ermitteln */
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Absender ermitteln */
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* From aus Prefix ermitteln */
if( Req->argc == 1 )
{
- /* an anderen Server forwarden */
+ /* forward? */
target = Client_Search( Req->argv[0] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* From aus Prefix ermitteln */
+ /* use prefix to determine "From" */
if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client;
if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
if( Req->argc == 2 )
{
- /* an anderen Server forwarden */
+ /* forward to another server? */
target = Client_Search( Req->argv[1] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
- if( target != Client_ThisServer( ))
- {
- /* Ok, anderer Server ist das Ziel: forwarden */
+ if( target != Client_ThisServer( )) {
+ /* target is another server, forward */
return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] );
}
}
chan = Channel_Search( ptr );
if( chan )
{
- /* Namen ausgeben */
+ /* print name */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
}
if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) return DISCONNECTED;
- /* naechsten Namen ermitteln */
+ /* get next channel name */
ptr = strtok( NULL, "," );
}
return CONNECTED;
}
- /* alle Channels durchgehen */
chan = Channel_First( );
while( chan )
{
- /* Namen ausgeben */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
- /* naechster Channel */
chan = Channel_Next( chan );
}
- /* Nun noch alle Clients ausgeben, die in keinem Channel sind */
+ /* Now print all clients which are not in any channel */
c = Client_First( );
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
while( c )
{
if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' )))
{
- /* Okay, das ist ein User: anhaengen */
+ /* its a user, concatenate ... */
if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
{
- /* Zeile wird zu lang: senden! */
+ /* Line is gwoing too long, send now */
if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
}
}
- /* naechster Client */
c = Client_Next( c );
}
if( rpl[strlen( rpl ) - 1] != ':')
{
- /* es wurden User gefunden */
if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
}
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if (Req->argc > 2)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
- /* From aus Prefix ermitteln */
+ /* use prefix to determine "From" */
if (Client_Type(Client) == CLIENT_SERVER)
from = Client_Search(Req->prefix);
else
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix);
if (Req->argc == 2) {
- /* an anderen Server forwarden */
+ /* forward to another server? */
target = Client_Search( Req->argv[1] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
if( target != Client_ThisServer()) {
- /* Ok, anderer Server ist das Ziel: forwarden */
+ /* forward to another server */
return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] );
}
}
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* From aus Prefix ermitteln */
if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client;
if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
if( Req->argc == 1 )
{
- /* an anderen Server forwarden */
target = Client_Search( Req->argv[0] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
if( target != Client_ThisServer( ))
{
- /* Ok, anderer Server ist das Ziel: forwarden */
return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
}
}
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if( Req->argc > 5 ) max = 5;
c = Client_Search( Req->argv[i] );
if( c && ( Client_Type( c ) == CLIENT_USER ))
{
- /* Dieser Nick ist "online" */
+ /* This Nick is "online" */
strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl ));
strlcat( rpl, "=", sizeof( rpl ));
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ziel suchen */
blob - 1091852bbb0865da87c06a6275c91bc0961d95c7
blob + 16d1641b5cea8cb875daa7077f91ae2dc9d5e1bc
--- src/ngircd/irc-login.c
+++ src/ngircd/irc-login.c
info = Req->argv[0];
}
- /* Nick ueberpruefen */
c = Client_Search(nick);
if(c) {
- /* Der neue Nick ist auf diesem Server bereits registriert:
- * sowohl der neue, als auch der alte Client muessen nun
- * disconnectiert werden. */
+ /*
+ * the new nick is already present on this server:
+ * the new and the old one have to be disconnected now.
+ */
Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
Kill_Nick( Req->argv[0], "Nick collision" );
return CONNECTED;
}
- /* Server, zu dem der Client connectiert ist, suchen */
+ /* Find the Server this client is connected to */
intr_c = Client_GetFromToken(Client, token);
if( ! intr_c )
{
return CONNECTED;
}
- /* Neue Client-Struktur anlegen */
c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
token, modes, info, true);
if( ! c )
{
- /* Eine neue Client-Struktur konnte nicht angelegt werden.
- * Der Client muss disconnectiert werden, damit der Netz-
- * status konsistent bleibt. */
+ /* out of memory, need to disconnect client to keep network state consistent */
Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
Kill_Nick( Req->argv[0], "Server error" );
return CONNECTED;
target = Client_Search( Req->prefix );
if( ! target )
{
- /* Den Client kennen wir nicht (mehr), also nichts zu tun. */
Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
return CONNECTED;
}
strlcat(quitmsg, "\"", sizeof quitmsg );
}
- /* User, Service, oder noch nicht registriert */
+ /* User, Service, or not yet registered */
Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
return DISCONNECTED;
assert(Client != NULL);
assert(Req != NULL);
- /* Wrong number of arguments? */
if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client));
blob - ba28f83e8e97a634b8470e9e8c06ad1eeae2c0af
blob + 8e08565030f4d5c91a77ea67ebdf948dce9e4aaa
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if(( Req->argc == 1 ) && (Req->argv[0][0] ))
{
- /* AWAY setzen */
Client_SetAway( Client, Req->argv[0] );
Client_ModeAdd( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
}
else
{
- /* AWAY loeschen */
Client_ModeDel( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
static bool
Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask )
{
- /* Bestaetigung an Client schicken & andere Server sowie Channel-User informieren */
-
bool ok;
if( Client_Type( Client ) == CLIENT_USER )
{
- /* Bestaetigung an Client */
+ /* send confirmation to client */
ok = IRC_WriteStrClientPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
}
else ok = true;
- /* an andere Server */
+ /* to other servers */
IRC_WriteStrServersPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
- /* und lokale User im Channel */
+ /* and local users in channel */
IRC_WriteStrChannelPrefix( Client, Channel, Prefix, false, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
return ok;
blob - c9286d7015e4598d1d0c09ef7694160cb39bc22d
blob + b0271df2576a99dff7f3d493034a0765e53b57e3
--- src/ngircd/irc-oper.c
+++ src/ngircd/irc-oper.c
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.29 2007/08/02 10:14:26 fw Exp $";
-
#include "imp.h"
#include <assert.h>
#include <stdlib.h>
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* Operator suchen */
for( i = 0; i < Conf_Oper_Count; i++)
{
if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
if( i >= Conf_Oper_Count )
return Bad_OperPass(Client, Req->argv[0], "not configured");
- /* Stimmt das Passwort? */
if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
return Bad_OperPass(Client, Conf_Oper[i].name, "Bad password");
- /* Authorized Mask? */
if( Conf_Oper[i].mask && (! Match( Conf_Oper[i].mask, Client_Mask( Client ) )))
return Bad_OperPass(Client, Conf_Oper[i].mask, "hostmask check failed" );
if( ! Client_HasMode( Client, 'o' ))
{
- /* noch kein o-Mode gesetzt */
Client_ModeAdd( Client, 'o' );
if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
blob - f1b817c033dd2bcdb0d84246bcc4f6b8c6d8bfa5
blob + 11ff54f869cf127f6847d62bf7aed1f359f7f5c3
--- src/ngircd/irc-server.c
+++ src/ngircd/irc-server.c
LogDebug("Connection %d: got SERVER command (new server link) ...",
Client_Conn(Client));
- /* Falsche Anzahl Parameter? */
if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* Ist dieser Server bei uns konfiguriert? */
+ /* Ist this server configured on out side? */
for( i = 0; i < MAX_SERVERS; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
if( i >= MAX_SERVERS )
{
- /* Server ist nicht konfiguriert! */
Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
return DISCONNECTED;
}
if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 )
{
- /* Falsches Passwort */
+ /* wrong password */
Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
return DISCONNECTED;
}
- /* Ist ein Server mit dieser ID bereits registriert? */
+ /* Is there a registered server with this ID? */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
- /* Server-Strukturen fuellen ;-) */
Client_SetID( Client, Req->argv[0] );
Client_SetHops( Client, 1 );
Client_SetInfo( Client, Req->argv[Req->argc - 1] );
- /* Meldet sich der Server bei uns an (d.h., bauen nicht wir
- * selber die Verbindung zu einem anderen Server auf)? */
+ /* Is this server registering on our side, or are we connecting to
+ * a remote server? */
con = Client_Conn( Client );
if( Client_Token( Client ) != TOKEN_OUTBOUND )
{
- /* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */
+ /* Incoming connection, send user/pass */
ok = true;
if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd_out, NGIRCd_ProtoID )) ok = false;
else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
}
else
{
- /* Ausgehende verbindung, SERVER und PASS wurden von uns bereits
- * an die Gegenseite uerbermittelt */
+ /* outgoing connect, we already sent SERVER and PASS to the peer */
Client_SetToken( Client, atoi( Req->argv[1] ));
}
Client_SetType(Client, CLIENT_UNKNOWNSERVER);
#ifdef ZLIB
- /* Kompression initialisieren, wenn erforderlich */
- if( strchr( Client_Flags( Client ), 'Z' ))
- {
- if( ! Zip_InitConn( con ))
- {
- /* Fehler! */
- Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
- return DISCONNECTED;
- }
+ if (strchr(Client_Flags(Client), 'Z') && !Zip_InitConn(con)) {
+ Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
+ return DISCONNECTED;
}
#endif
}
else if( Client_Type( Client ) == CLIENT_SERVER )
{
- /* Neuer Server wird im Netz angekuendigt */
+ /* New server is being introduced to the network */
- /* Falsche Anzahl Parameter? */
if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
- /* Ist ein Server mit dieser ID bereits registriert? */
+ /* check for existing server with same ID */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
- /* Ueberfluessige Hostnamen aus Info-Text entfernen */
+ /* remove superfluous hostnames from Info-Text */
ptr = strchr( Req->argv[3] + 2, '[' );
if( ! ptr ) ptr = Req->argv[3];
from = Client_Search( Req->prefix );
if( ! from )
{
- /* Hm, Server, der diesen einfuehrt, ist nicht bekannt!? */
+ /* Uh, Server, that introduced the new server is unknown?! */
Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true);
return DISCONNECTED;
}
- /* Neue Client-Struktur anlegen */
c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, true);
- if( ! c )
- {
- /* Neue Client-Struktur konnte nicht angelegt werden */
+ if (!c) {
Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true);
return DISCONNECTED;
}
- /* Log-Meldung zusammenbauen und ausgeben */
if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
else strcpy( str, "" );
Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
- /* Andere Server informieren */
+ /* notify other servers */
IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
return CONNECTED;
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
{
is_op = is_voiced = false;
- /* Prefixe abschneiden */
+ /* cut off prefixes */
while(( *ptr == '@' ) || ( *ptr == '+' ))
{
if( *ptr == '@' ) is_op = true;
if( is_op ) Channel_UserModeAdd( chan, c, 'o' );
if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
- /* im Channel bekannt machen */
+ /* announce to channel... */
IRC_WriteStrChannelPrefix( Client, chan, c, false, "JOIN :%s", channame );
- /* Channel-User-Modes setzen */
+ /* set Channel-User-Modes */
strlcpy( modes, Channel_UserModes( chan, c ), sizeof( modes ));
if( modes[0] )
{
- /* Modes im Channel bekannt machen */
+ /* send modes to channel */
IRC_WriteStrChannelPrefix( Client, chan, Client, false, "MODE %s +%s %s", channame, modes, Client_ID( c ));
}
}
else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame );
- /* naechsten Nick suchen */
+ /* search for next Nick */
ptr = strtok( NULL, "," );
}
- /* an andere Server weiterleiten */
+ /* forward to other servers */
if( nick_out[0] != '\0' ) IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], nick_out );
return CONNECTED;
assert( Client != NULL );
assert( Req != NULL );
- /* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
target = Client_Search( Req->argv[0] );
if( ! target )
{
- /* Den Server kennen wir nicht (mehr), also nichts zu tun. */
Log( LOG_WARNING, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
return CONNECTED;
}
if( Client_Conn( target ) > NONE )
{
- /* dieser Server hat die Connection */
+ /* This server has the connection */
if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], true);
else Conn_Close( Client_Conn( target ), msg, NULL, true);
return DISCONNECTED;
}
else
{
- /* Verbindung hielt anderer Server */
+ /* connection was on another server */
Client_Destroy( target, msg, Req->argv[1], false );
return CONNECTED;
}
} /* IRC_SQUIT */
-
/* -eof- */
blob - 8239c150cadba6f14a111cf2827b5c641b06730f
blob + ea0f5f8a288158531e55952212197b360690102e
--- src/ngircd/irc-write.c
+++ src/ngircd/irc-write.c
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-write.c,v 1.21 2006/08/12 11:56:24 fw Exp $";
-
#include "imp.h"
#include <assert.h>
#ifdef PROTOTYPES
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* an den Client selber */
+ /* to the client itself */
ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer );
return ok;
va_dcl
#endif
{
- /* Text an Clients, lokal bzw. remote, senden. */
+ /* send text to local and remote clients */
char buffer[1000];
va_list ap;
} /* IRC_WriteStrChannel */
+
+/**
+ * send message to all clients in the same channel, but only send message
+ * once per remote server.
+ */
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... )
Conn_ClearFlags( );
- /* An alle Clients, die in den selben Channels sind.
- * Dabei aber nur einmal je Remote-Server */
cl2chan = Channel_FirstMember( Chan );
while( cl2chan )
{
if( c && ( c != Client ))
{
- /* Ok, anderer Client */
+ /* Ok, another Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
cl2chan = Channel_NextMember( Chan, cl2chan );
}
- /* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
- /* muessen Daten ueber diese Verbindung verschickt werden? */
+ /* do we need to send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
- /* naechste Verbindung testen */
conn = Conn_Next( conn );
}
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* an den Client selber */
IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer );
} /* IRC_WriteStrServers */
} /* IRC_WriteStrServersPrefixFlag */
+/**
+ * send message to all clients that are in the same channels as the client sending this message.
+ * only send message once per reote server.
+ */
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... )
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
- /* initialisieren */
Conn_ClearFlags( );
- /* An alle Clients, die in einem Channel mit dem "Ausloeser" sind,
- * den Text schicken. An Remote-Server aber jeweils nur einmal. */
chan_cl2chan = Channel_FirstChannelOf( Client );
while( chan_cl2chan )
{
- /* Channel des Users durchsuchen */
chan = Channel_GetChannel( chan_cl2chan );
cl2chan = Channel_FirstMember( chan );
while( cl2chan )
if( c && ( c != Client ))
{
- /* Ok, anderer Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
cl2chan = Channel_NextMember( chan, cl2chan );
}
- /* naechsten Channel */
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
}
- /* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
- /* muessen ueber diese Verbindung Daten gesendet werden? */
+ /* send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER ) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
- /* naechste Verbindung testen */
conn = Conn_Next( conn );
}
return ok;
blob - 5559a2c6ada62e176d1e39ac0f3fda7d6dc4cb09
blob + 5a81b5b3e03083451d65150b033e04ce4d873151
--- src/ngircd/log.c
+++ src/ngircd/log.c
#ifndef LOG_LOCAL5
#define LOG_LOCAL5 0
#endif
- /* Syslog initialisieren */
openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 );
#endif
- /* Hello World! */
Log( LOG_NOTICE, "%s started.", NGIRCd_Version );
- /* Informationen uebern den "Operation Mode" */
+ /* Information about "Operation Mode" */
Init_Txt[0] = '\0';
#ifdef DEBUG
if( NGIRCd_Debug )
#ifdef DEBUG
-
GLOBAL void
Log_InitErrorfile( void )
{
- /* "Error-Log" initialisieren: stderr in Datei umlenken. Dort
- * landen z.B. alle Ausgaben von assert()-Aufrufen. */
-
- /* Dateiname zusammen bauen */
snprintf( Error_File, sizeof Error_File, "%s/%s-%ld.err", ERROR_DIR, PACKAGE_NAME, (long)getpid( ));
- /* stderr umlenken */
fflush( stderr );
if( ! freopen( Error_File, "w", stderr ))
{
return;
}
- /* Einige Infos in das Error-File schreiben */
fputs( ctime( &NGIRCd_Start ), stderr );
fprintf( stderr, "%s started.\n", NGIRCd_Version );
fprintf( stderr, "Activating: %s\n\n", Init_Txt[0] ? Init_Txt : "-" );
fflush( stderr );
-#ifdef DEBUG
- Log( LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File );
-#endif
+ Log(LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File);
} /* Log_InitErrfile */
-
#endif
#endif
#ifdef SYSLOG
- /* syslog abmelden */
- closelog( );
+ closelog();
#endif
} /* Log_Exit */
blob - ad1168ad49a7969811e9bb6b95d51d1bbace53c9
blob + 95c377a1fa5c0ce59ac2d6a870fd18e252572567
--- src/ngircd/ngircd.c
+++ src/ngircd/ngircd.c
Fill_Version( );
- /* Kommandozeile parsen */
+ /* parse conmmand line */
for( i = 1; i < argc; i++ )
{
ok = false;
if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
{
- /* Lange Option */
-
+ /* long option */
if( strcmp( argv[i], "--config" ) == 0 )
{
if( i + 1 < argc )
}
else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
{
- /* Kurze Option */
+ /* short option */
for( n = 1; n < strlen( argv[i] ); n++ )
{
ok = false;
}
}
- /* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
+ /* Debug-Level (for IRCs "VERSION" command) */
NGIRCd_DebugLevel[0] = '\0';
#ifdef DEBUG
if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
}
#endif
- /* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
if( configtest )
{
Show_Version( ); puts( "" );
if( ! NGIRCd_NoDaemon ) Log_InitErrorfile( );
#endif
- /* Signal-Handler initialisieren */
Initialize_Signal_Handler( );
- /* Protokoll- und Server-Identifikation erzeugen. Die vom ngIRCd
- * beim PASS-Befehl verwendete Syntax sowie die erweiterten Flags
- * sind in doc/Protocol.txt beschrieben. */
+ /*
+ * create protocol and server identification.
+ * The syntax used by ngIRCd in PASS commands and the extended flags
+ * are described in doc/Protocol.txt
+ */
#ifdef IRCPLUS
snprintf( NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS );
#ifdef ZLIB
#endif
LogDebug("Protocol and server ID is \"%s\".", NGIRCd_ProtoID);
- /* Vordefinierte Channels anlegen */
Channel_InitPredefined( );
- /* Listen-Ports initialisieren */
if( Conn_InitListeners( ) < 1 )
{
Log( LOG_ALERT, "Server isn't listening on a single port!" );
static void
Initialize_Signal_Handler( void )
{
- /* Signal-Handler initialisieren: einige Signale
- * werden ignoriert, andere speziell behandelt. */
-
#ifdef HAVE_SIGACTION
- /* sigaction() ist vorhanden */
-
struct sigaction saction;
- /* Signal-Struktur initialisieren */
memset( &saction, 0, sizeof( saction ));
saction.sa_handler = Signal_Handler;
#ifdef SA_RESTART
saction.sa_flags |= SA_NOCLDWAIT;
#endif
- /* Signal-Handler einhaengen */
sigaction(SIGINT, &saction, NULL);
sigaction(SIGQUIT, &saction, NULL);
sigaction(SIGTERM, &saction, NULL);
sigaction(SIGHUP, &saction, NULL);
sigaction(SIGCHLD, &saction, NULL);
- /* einige Signale ignorieren */
+ /* we handle write errors properly; ignore SIGPIPE */
saction.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &saction, NULL);
#else
- /* kein sigaction() vorhanden */
-
- /* Signal-Handler einhaengen */
signal(SIGINT, Signal_Handler);
signal(SIGQUIT, Signal_Handler);
signal(SIGTERM, Signal_Handler);
signal(SIGHUP, Signal_Handler);
signal(SIGCHLD, Signal_Handler);
- /* einige Signale ignorieren */
signal(SIGPIPE, SIG_IGN);
#endif
} /* Initialize_Signal_Handler */
case SIGTERM:
case SIGINT:
case SIGQUIT:
- /* wir soll(t)en uns wohl beenden ... */
+ /* shut down sever */
NGIRCd_SignalQuit = true;
break;
case SIGHUP:
- /* Konfiguration neu einlesen: */
+ /* re-read configuration */
NGIRCd_SignalRehash = true;
break;
case SIGCHLD:
- /* Child-Prozess wurde beendet. Zombies vermeiden: */
- while( waitpid( -1, NULL, WNOHANG ) > 0);
+ /* child-process exited, avoid zombies */
+ while (waitpid( -1, NULL, WNOHANG) > 0)
+ ;
break;
#ifdef DEBUG
default:
blob - 6801997141b64740a0776a4b8e0888df54fbdc67
blob + 5e3f08d0cf77fa26b2da6ad185ccd6f066b3025b
--- src/ngircd/parse.c
+++ src/ngircd/parse.c
Init_Request( &req );
- /* Fuehrendes und folgendes "Geraffel" verwerfen */
+ /* remove leading & trailing whitespace */
ngt_TrimStr( Request );
- /* gibt es ein Prefix? */
if( Request[0] == ':' )
{
- /* Prefix vorhanden */
+ /* Prefix */
req.prefix = Request + 1;
ptr = strchr( Request, ' ' );
if( ! ptr )
}
*ptr = '\0';
#ifndef STRICT_RFC
- /* multiple Leerzeichen als Trenner zwischen
- * Prefix und Befehl ignorieren */
+ /* ignore multiple spaces between prefix and command */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
start = ptr + 1;
}
else start = Request;
- /* Befehl */
ptr = strchr( start, ' ' );
if( ptr )
{
*ptr = '\0';
#ifndef STRICT_RFC
- /* multiple Leerzeichen als Trenner vor
- * Parametern ignorieren */
+ /* ignore multiple spaces between parameters */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
}
req.command = start;
- /* Argumente, Parameter */
+ /* Arguments, Parameters */
if( ptr )
{
- /* Prinzipiell gibt es welche :-) */
start = ptr + 1;
while( start )
{
- /* Parameter-String "zerlegen" */
if( start[0] == ':' )
{
req.argv[req.argc] = start + 1;
{
*ptr = '\0';
#ifndef STRICT_RFC
- /* multiple Leerzeichen als
- * Parametertrenner ignorieren */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
}
}
}
- /* Daten validieren */
if( ! Validate_Prefix( Idx, &req, &closed )) return ! closed;
if( ! Validate_Command( Idx, &req, &closed )) return ! closed;
if( ! Validate_Args( Idx, &req, &closed )) return ! closed;
*Closed = false;
- /* ist ueberhaupt ein Prefix vorhanden? */
if( ! Req->prefix ) return true;
- /* Client-Struktur der Connection ermitteln */
client = Conn_GetClient( Idx );
assert( client != NULL );
- /* nur validieren, wenn bereits registrierte Verbindung */
+ /* only validate if this connection is already registered */
if(( Client_Type( client ) != CLIENT_USER ) && ( Client_Type( client ) != CLIENT_SERVER ) && ( Client_Type( client ) != CLIENT_SERVICE ))
{
- /* noch nicht registrierte Verbindung.
- * Das Prefix wird ignoriert. */
+ /* not registered, ignore prefix */
Req->prefix = NULL;
return true;
}
- /* pruefen, ob der im Prefix angegebene Client bekannt ist */
+ /* check if client in prefix is known */
c = Client_Search( Req->prefix );
if( ! c )
{
- /* im Prefix angegebener Client ist nicht bekannt */
Log( LOG_ERR, "Invalid prefix \"%s\", client not known (connection %d, command %s)!?", Req->prefix, Idx, Req->command );
if( ! Conn_WriteStr( Idx, "ERROR :Invalid prefix \"%s\", client not known!?", Req->prefix )) *Closed = true;
return false;
}
- /* pruefen, ob der Client mit dem angegebenen Prefix in Richtung
- * des Senders liegt, d.h. sicherstellen, dass das Prefix nicht
- * gefaelscht ist */
+ /* check if the client named in the prefix is expected
+ * to come from that direction */
if( Client_NextHop( c ) != client )
{
- /* das angegebene Prefix ist aus dieser Richtung, also
- * aus der gegebenen Connection, ungueltig! */
Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Conn_GetClient( Idx )), Idx, Req->command );
Conn_Close( Idx, NULL, "Spoofed prefix", true);
*Closed = true;
static bool
Handle_Request( CONN_ID Idx, REQUEST *Req )
{
- /* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler
- * wird die Verbindung geschlossen und false geliefert. */
CLIENT *client;
bool result = true;
int client_type;
cmd = My_Commands;
while (cmd->name) {
- /* Befehl suchen */
if (strcasecmp(Req->command, cmd->name) != 0) {
cmd++;
continue;