mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 10:20:28 +00:00
- Es werden fuer alle Server eigene Token generiert,
- QUIT von einem Server fuer einen User wird an andere Server geforwarded, - ebenso NICK-Befehle, die "fremde" User einfuehren.
This commit is contained in:
parent
2714a94f43
commit
a53857b4c7
@ -9,7 +9,7 @@
|
||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: client.c,v 1.25 2002/01/07 15:31:00 alex Exp $
|
||||
* $Id: client.c,v 1.26 2002/01/07 23:42:12 alex Exp $
|
||||
*
|
||||
* client.c: Management aller Clients
|
||||
*
|
||||
@ -21,6 +21,11 @@
|
||||
* Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
|
||||
*
|
||||
* $Log: client.c,v $
|
||||
* Revision 1.26 2002/01/07 23:42:12 alex
|
||||
* - Es werden fuer alle Server eigene Token generiert,
|
||||
* - QUIT von einem Server fuer einen User wird an andere Server geforwarded,
|
||||
* - ebenso NICK-Befehle, die "fremde" User einfuehren.
|
||||
*
|
||||
* Revision 1.25 2002/01/07 15:31:00 alex
|
||||
* - Bei Log-Meldungen ueber Clients wird nun immer die "Client Mask" verwendet.
|
||||
*
|
||||
@ -137,6 +142,7 @@ LOCAL CHAR GetID_Buffer[CLIENT_ID_LEN];
|
||||
|
||||
|
||||
LOCAL CLIENT *New_Client_Struct( VOID );
|
||||
LOCAL VOID Generate_MyToken( CLIENT *Client );
|
||||
|
||||
|
||||
GLOBAL VOID Client_Init( VOID )
|
||||
@ -237,6 +243,7 @@ GLOBAL CLIENT *Client_New( CONN_ID Idx, CLIENT *Introducer, INT Type, CHAR *ID,
|
||||
client->hops = Hops;
|
||||
client->token = Token;
|
||||
if( Modes ) Client_SetModes( client, Modes );
|
||||
if( Type == CLIENT_SERVER ) Generate_MyToken( client );
|
||||
|
||||
/* Verketten */
|
||||
client->next = My_Clients;
|
||||
@ -279,7 +286,7 @@ GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg )
|
||||
{
|
||||
if( c->conn_id != NONE )
|
||||
{
|
||||
/* Ein lokaler User. Andere Server informieren! */
|
||||
/* Ein lokaler User. Alle andere Server informieren! */
|
||||
Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", Client_Mask( c ), c->conn_id, txt );
|
||||
|
||||
if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
|
||||
@ -287,7 +294,13 @@ GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg )
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remote User. Andere Server informieren, ausser denen,
|
||||
* die "in Richtung dem liegen", auf dem der User registriert
|
||||
* ist. Von denen haben wir das QUIT ja wohl bekommen. */
|
||||
Log( LOG_DEBUG, "User \"%s\" unregistered: %s", Client_Mask( c ), txt );
|
||||
|
||||
if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :%s", FwdMsg );
|
||||
else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :" );
|
||||
}
|
||||
}
|
||||
else if( c->type == CLIENT_SERVER )
|
||||
@ -374,6 +387,7 @@ GLOBAL VOID Client_SetType( CLIENT *Client, INT Type )
|
||||
{
|
||||
assert( Client != NULL );
|
||||
Client->type = Type;
|
||||
if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
|
||||
} /* Client_SetType */
|
||||
|
||||
|
||||
@ -590,6 +604,13 @@ GLOBAL INT Client_Token( CLIENT *Client )
|
||||
} /* Client_Token */
|
||||
|
||||
|
||||
GLOBAL INT Client_MyToken( CLIENT *Client )
|
||||
{
|
||||
assert( Client != NULL );
|
||||
return Client->mytoken;
|
||||
} /* Client_MyToken */
|
||||
|
||||
|
||||
GLOBAL CLIENT *Client_NextHop( CLIENT *Client )
|
||||
{
|
||||
CLIENT *c;
|
||||
@ -757,9 +778,33 @@ LOCAL CLIENT *New_Client_Struct( VOID )
|
||||
c->oper_by_me = FALSE;
|
||||
c->hops = -1;
|
||||
c->token = -1;
|
||||
c->mytoken = -1;
|
||||
|
||||
return c;
|
||||
} /* New_Client */
|
||||
|
||||
|
||||
LOCAL VOID Generate_MyToken( CLIENT *Client )
|
||||
{
|
||||
CLIENT *c;
|
||||
INT token;
|
||||
|
||||
c = My_Clients;
|
||||
token = 2;
|
||||
while( c )
|
||||
{
|
||||
if( c->mytoken == token )
|
||||
{
|
||||
/* Das Token wurde bereits vergeben */
|
||||
token++;
|
||||
c = My_Clients;
|
||||
continue;
|
||||
}
|
||||
else c = c->next;
|
||||
}
|
||||
Client->mytoken = token;
|
||||
Log( LOG_DEBUG, "Assigned token %d to server \"%s\".", token, Client->id );
|
||||
} /* Generate_MyToken */
|
||||
|
||||
|
||||
/* -eof- */
|
||||
|
@ -9,11 +9,16 @@
|
||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: client.h,v 1.17 2002/01/06 15:18:14 alex Exp $
|
||||
* $Id: client.h,v 1.18 2002/01/07 23:42:12 alex Exp $
|
||||
*
|
||||
* client.h: Konfiguration des ngircd (Header)
|
||||
*
|
||||
* $Log: client.h,v $
|
||||
* Revision 1.18 2002/01/07 23:42:12 alex
|
||||
* - Es werden fuer alle Server eigene Token generiert,
|
||||
* - QUIT von einem Server fuer einen User wird an andere Server geforwarded,
|
||||
* - ebenso NICK-Befehle, die "fremde" User einfuehren.
|
||||
*
|
||||
* Revision 1.17 2002/01/06 15:18:14 alex
|
||||
* - Loglevel und Meldungen nochmals geaendert. Level passen nun besser.
|
||||
*
|
||||
@ -107,7 +112,7 @@ typedef struct _CLIENT
|
||||
CHAR info[CLIENT_INFO_LEN]; /* Langer Benutzername (User) bzw. Infotext (Server) */
|
||||
CHANNEL *channels[MAX_CHANNELS];/* Channel, in denen der Client Mitglied ist */
|
||||
CHAR modes[CLIENT_MODE_LEN]; /* Client Modes */
|
||||
INT hops, token; /* "Hops" und "Token" (-> SERVER-Befehl) */
|
||||
INT hops, token, mytoken; /* "Hops" und "Token" (-> SERVER-Befehl) */
|
||||
BOOLEAN oper_by_me; /* IRC-Operator-Status durch diesen Server? */
|
||||
} CLIENT;
|
||||
#else
|
||||
@ -148,6 +153,7 @@ GLOBAL CLIENT *Client_Introducer( CLIENT *Client );
|
||||
GLOBAL BOOLEAN Client_OperByMe( CLIENT *Client );
|
||||
GLOBAL INT Client_Hops( CLIENT *Client );
|
||||
GLOBAL INT Client_Token( CLIENT *Client );
|
||||
GLOBAL INT Client_MyToken( CLIENT *Client );
|
||||
GLOBAL CLIENT *Client_NextHop( CLIENT *Client );
|
||||
|
||||
GLOBAL BOOLEAN Client_HasMode( CLIENT *Client, CHAR Mode );
|
||||
|
@ -9,11 +9,16 @@
|
||||
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
||||
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
||||
*
|
||||
* $Id: irc.c,v 1.32 2002/01/07 16:02:36 alex Exp $
|
||||
* $Id: irc.c,v 1.33 2002/01/07 23:42:12 alex Exp $
|
||||
*
|
||||
* irc.c: IRC-Befehle
|
||||
*
|
||||
* $Log: irc.c,v $
|
||||
* Revision 1.33 2002/01/07 23:42:12 alex
|
||||
* - Es werden fuer alle Server eigene Token generiert,
|
||||
* - QUIT von einem Server fuer einen User wird an andere Server geforwarded,
|
||||
* - ebenso NICK-Befehle, die "fremde" User einfuehren.
|
||||
*
|
||||
* Revision 1.32 2002/01/07 16:02:36 alex
|
||||
* - Loglevel von Remote-Mode-Aenderungen angepasst (nun Debug).
|
||||
* - Im Debug-Mode werden nun auch PING's protokolliert.
|
||||
@ -380,7 +385,10 @@ GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
||||
|
||||
Client_SetType( Client, CLIENT_SERVER );
|
||||
|
||||
/* Unsere User und Server bekanntmachen */
|
||||
/* Unsere User und Server dem neuen Server melden */
|
||||
/* ... */
|
||||
|
||||
/* neuen Servern bei anderen bekannt machen */
|
||||
/* ... */
|
||||
|
||||
return CONNECTED;
|
||||
@ -518,7 +526,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
|
||||
/* Der neue Nick ist auf diesem Server bereits registriert:
|
||||
* sowohl der neue, als auch der alte Client muessen nun
|
||||
* disconnectiert werden. */
|
||||
Log( LOG_ERR, "Server %s introduces already registered nick %s!", Client_ID( Client ), Req->argv[0] );
|
||||
Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
|
||||
Kill_Nick( Req->argv[0] );
|
||||
return CONNECTED;
|
||||
}
|
||||
@ -527,7 +535,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
|
||||
intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
|
||||
if( ! intr_c )
|
||||
{
|
||||
Log( LOG_ERR, "Server %s introduces nick %s with unknown host server!?", Client_ID( Client ), Req->argv[0] );
|
||||
Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
|
||||
Kill_Nick( Req->argv[0] );
|
||||
return CONNECTED;
|
||||
}
|
||||
@ -546,6 +554,9 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
|
||||
|
||||
Log( LOG_DEBUG, "User \"%s\" registered (via %s, on %s, %d hop%s).", Client_Mask( c ), Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
|
||||
|
||||
/* Andere Server, ausser dem Introducer, informieren */
|
||||
IRC_WriteStrServersPrefix( Client, Client, "NICK %s %d %s %s %d %s :%s", Req->argv[0], atoi( Req->argv[1] ) + 1, Req->argv[2], Req->argv[3], Client_MyToken( intr_c ), Req->argv[5], Req->argv[6] );
|
||||
|
||||
return CONNECTED;
|
||||
}
|
||||
else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
|
||||
@ -611,7 +622,7 @@ GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
|
||||
target = Client_Search( Req->prefix );
|
||||
if( ! target )
|
||||
{
|
||||
Log( LOG_ERR, "Got QUIT from %s for unknown server!?", Client_ID( Client ));
|
||||
Log( LOG_ERR, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
|
||||
return CONNECTED;
|
||||
}
|
||||
|
||||
@ -675,7 +686,7 @@ GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
|
||||
if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NOORIGIN_MSG, Client_ID( Client ));
|
||||
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
|
||||
|
||||
Log( LOG_DEBUG, "Connection %d: Got PING, sending PONG ...", Client_Conn( Client ));
|
||||
Log( LOG_DEBUG, "Connection %d: got PING, sending PONG ...", Client_Conn( Client ));
|
||||
return IRC_WriteStrClient( Client, "PONG %s :%s", Client_ID( Client_ThisServer( )), Client_ID( Client ));
|
||||
} /* IRC_PING */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user