1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-13 18:30:27 +00:00

- Bei einem JOIN in einen persistenten Channel werden nun evtl. zu setzende

User-Modes korrekt in den Channel gemeldet.
This commit is contained in:
Alexander Barton 2002-08-26 23:39:22 +00:00
parent 7b6cfc17c4
commit d645ce86e9
9 changed files with 181 additions and 25 deletions

View File

@ -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: channel.c,v 1.28 2002/06/09 13:15:58 alex Exp $
* $Id: channel.c,v 1.29 2002/08/26 23:39:22 alex Exp $
*
* channel.c: Management der Channels
*/
@ -454,6 +454,7 @@ Channel_ModeDel( CHANNEL *Chan, CHAR Mode )
CHAR x[2], *p;
assert( Chan != NULL );
assert( Mode > ' ' );
x[0] = Mode; x[1] = '\0';
@ -482,6 +483,7 @@ Channel_UserModeAdd( CHANNEL *Chan, CLIENT *Client, CHAR Mode )
assert( Chan != NULL );
assert( Client != NULL );
assert( Mode > ' ' );
cl2chan = Get_Cl2Chan( Chan, Client );
assert( cl2chan != NULL );

View File

@ -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: irc-channel.c,v 1.10 2002/06/26 15:44:15 alex Exp $
* $Id: irc-channel.c,v 1.11 2002/08/26 23:39:22 alex Exp $
*
* irc-channel.c: IRC-Channel-Befehle
*/
@ -157,7 +157,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
if( modes[1] )
{
/* Modes im Channel bekannt machen */
IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "MODE %s %s :%s", channame, modes, Client_ID( target ));
IRC_WriteStrChannelPrefix( Client, chan, target, FALSE, "MODE %s +%s :%s", channame, &modes[1], Client_ID( target ));
}
if( Client_Type( Client ) == CLIENT_USER )

View File

@ -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: irc-mode.c,v 1.7 2002/06/02 15:14:22 alex Exp $
* $Id: irc-mode.c,v 1.8 2002/08/26 23:39:22 alex Exp $
*
* irc-mode.c: IRC-Befehle zur Mode-Aenderung (MODE, AWAY, ...)
*/
@ -26,6 +26,7 @@
#include "channel.h"
#include "defines.h"
#include "irc-write.h"
#include "lists.h"
#include "log.h"
#include "parse.h"
#include "messages.h"
@ -34,6 +35,16 @@
#include "irc-mode.h"
LOCAL BOOLEAN Show_InviteList PARAMS(( CLIENT *Client, CHANNEL *Channel ));
LOCAL BOOLEAN Show_BanList PARAMS(( CLIENT *Client, CHANNEL *Channel ));
LOCAL BOOLEAN Add_Invite PARAMS(( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
LOCAL BOOLEAN Add_Ban PARAMS(( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
LOCAL BOOLEAN Del_Invite PARAMS(( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
LOCAL BOOLEAN Del_Ban PARAMS(( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
GLOBAL BOOLEAN
IRC_MODE( CLIENT *Client, REQUEST *Req )
{
@ -67,6 +78,43 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
if(( cl ) && ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if(( chan ) && ( Req->argc > 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Prefix fuer Antworten etc. ermitteln */
if( Client_Type( Client ) == CLIENT_SERVER )
{
prefix = Client_Search( Req->prefix );
if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
}
else prefix = Client;
if(( chan ) && (( Req->argc == 2 ) || ( Req->argc == 3 )))
{
/* pruefen, ob "Listen-Operation": Invite, Ban */
if(( Req->argv[1][0] == '-' ) || ( Req->argv[1][0] == '+' )) mode_ptr = &Req->argv[1][1];
else mode_ptr = &Req->argv[1][0];
if( Req->argc == 2 )
{
/* Liste anzeigen */
if( *mode_ptr == 'I' ) return Show_InviteList( prefix, chan );
if( *mode_ptr == 'b' ) return Show_BanList( prefix, chan );
}
else
{
if( Req->argv[1][0] == '+' )
{
/* Listen-Eintrag hinzufuegen */
if( *mode_ptr == 'I' ) return Add_Invite( prefix, chan, Req->argv[2] );
if( *mode_ptr == 'b' ) return Add_Ban( prefix, chan, Req->argv[2] );
}
else if( Req->argv[1][0] == '-' )
{
/* Listen-Eintrag loeschen */
if( *mode_ptr == 'I' ) return Del_Invite( prefix, chan, Req->argv[2] );
if( *mode_ptr == 'b' ) return Del_Ban( prefix, chan, Req->argv[2] );
}
}
}
/* Client ermitteln, wenn bei Channel-Modes mit 3 Parametern */
if(( chan ) && (Req->argc == 3 ))
{
@ -108,14 +156,6 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
else set = TRUE;
if(( *mode_ptr == '-' ) || ( *mode_ptr == '+' )) mode_ptr++;
}
/* Prefix fuer Antworten etc. ermitteln */
if( Client_Type( Client ) == CLIENT_SERVER )
{
prefix = Client_Search( Req->prefix );
if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
}
else prefix = Client;
/* Reply-String mit Aenderungen vorbereiten */
if( set ) strcpy( the_modes, "+" );
@ -387,4 +427,79 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
} /* IRC_AWAY */
LOCAL BOOLEAN
Show_InviteList( CLIENT *Client, CHANNEL *Channel )
{
assert( Client != NULL );
assert( Channel != NULL );
return IRC_WriteStrClient( Client, RPL_ENDOFINVITELIST_MSG, Client_ID( Client ), Channel_Name( Channel ));
} /* Show_InviteList */
LOCAL BOOLEAN
Show_BanList( CLIENT *Client, CHANNEL *Channel )
{
assert( Client != NULL );
assert( Channel != NULL );
return IRC_WriteStrClient( Client, RPL_ENDOFBANLIST_MSG, Client_ID( Client ), Channel_Name( Channel ));
} /* Show_BanList */
LOCAL BOOLEAN
Add_Invite( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
{
CHAR *mask;
assert( Client != NULL );
assert( Channel != NULL );
assert( Pattern != NULL );
mask = Lists_MakeMask( Pattern );
if( ! Lists_AddInvited( mask, Channel, FALSE )) return CONNECTED;
IRC_WriteStrChannelPrefix( Client, Channel, Client, TRUE, "MODE %s +I %s", Channel_Name( Channel ), mask );
if( Client_Type( Client ) == CLIENT_USER )
{
if( ! IRC_WriteStrClientPrefix( Client, Client, "MODE %s +I %s", Channel_Name( Channel ), mask )) return DISCONNECTED;
}
return CONNECTED;
} /* Add_Invite */
LOCAL BOOLEAN
Add_Ban( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
{
assert( Client != NULL );
assert( Channel != NULL );
assert( Pattern != NULL );
return CONNECTED;
} /* Add_Ban */
LOCAL BOOLEAN
Del_Invite( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
{
assert( Client != NULL );
assert( Channel != NULL );
assert( Pattern != NULL );
return CONNECTED;
} /* Del_Invite */
LOCAL BOOLEAN
Del_Ban( CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
{
assert( Client != NULL );
assert( Channel != NULL );
assert( Pattern != NULL );
return CONNECTED;
} /* Del_Ban */
/* -eof- */

View File

@ -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: irc-oper.c,v 1.5 2002/05/27 13:09:27 alex Exp $
* $Id: irc-oper.c,v 1.6 2002/08/26 23:39:22 alex Exp $
*
* irc-oper.c: IRC-Operator-Befehle
*/
@ -120,4 +120,25 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
} /* IRC_RESTART */
GLOBAL BOOLEAN
IRC_CONNECT(CLIENT *Client, REQUEST *Req )
{
/* Vorlaeufige Version zu Debug-Zwecken ... */
assert( Client != NULL );
assert( Req != NULL );
if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
/* Falsche Anzahl Parameter? */
if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
Log( LOG_NOTICE|LOG_snotice, "Got CONNECT command from \"%s\".", Client_Mask( Client ));
NGIRCd_Passive = FALSE;
return CONNECTED;
} /* IRC_CONNECT */
/* -eof- */

View File

@ -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: irc-oper.h,v 1.3 2002/05/27 13:09:27 alex Exp $
* $Id: irc-oper.h,v 1.4 2002/08/26 23:39:22 alex Exp $
*
* irc-oper.h: IRC-Operator-Befehle (Header)
*/
@ -22,6 +22,7 @@
GLOBAL BOOLEAN IRC_OPER PARAMS((CLIENT *Client, REQUEST *Req ));
GLOBAL BOOLEAN IRC_DIE PARAMS((CLIENT *Client, REQUEST *Req ));
GLOBAL BOOLEAN IRC_RESTART PARAMS((CLIENT *Client, REQUEST *Req ));
GLOBAL BOOLEAN IRC_CONNECT PARAMS((CLIENT *Client, REQUEST *Req ));
#endif

View File

@ -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: irc-server.c,v 1.12 2002/07/25 12:33:19 alex Exp $
* $Id: irc-server.c,v 1.13 2002/08/26 23:39:22 alex Exp $
*
* irc-server.c: IRC-Befehle fuer Server-Links
*/
@ -299,7 +299,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
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 );
else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\", channel \"%s\"!", ptr, channame );
/* naechsten Nick suchen */
ptr = strtok( NULL, "," );

View File

@ -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: lists.c,v 1.4 2002/07/15 16:35:21 alex Exp $
* $Id: lists.c,v 1.5 2002/08/26 23:39:22 alex Exp $
*
* lists.c: Verwaltung der "IRC-Listen": Ban, Invite, ...
*/
@ -25,6 +25,7 @@
#include "client.h"
#include "channel.h"
#include "log.h"
#include "match.h"
#include <stdlib.h>
#include <string.h>
@ -102,7 +103,8 @@ Lists_CheckInvited( CLIENT *Client, CHANNEL *Chan )
if( c2c->channel == Chan )
{
/* Ok, richtiger Channel. Passt die Maske? */
if( strcasecmp( Client_Mask( Client ), c2c->mask ) == 0 )
Log( LOG_DEBUG, "%s : %s", Client_Mask( Client ), c2c->mask );
if( Match( Client_Mask( Client ), c2c->mask ))
{
/* Treffer! */
if( c2c->onlyonce )
@ -124,14 +126,14 @@ Lists_CheckInvited( CLIENT *Client, CHANNEL *Chan )
GLOBAL BOOLEAN
Lists_AddInvited( CHAR *Pattern, CHANNEL *Chan, BOOLEAN OnlyOnce )
Lists_AddInvited( CHAR *Mask, CHANNEL *Chan, BOOLEAN OnlyOnce )
{
C2C *c2c;
assert( Pattern != NULL );
assert( Mask != NULL );
assert( Chan != NULL );
c2c = New_C2C( Pattern, Chan, OnlyOnce );
c2c = New_C2C( Mask, Chan, OnlyOnce );
if( ! c2c )
{
Log( LOG_ERR, "Can't add new invite list entry!" );
@ -142,7 +144,7 @@ Lists_AddInvited( CHAR *Pattern, CHANNEL *Chan, BOOLEAN OnlyOnce )
c2c->next = My_Invites;
My_Invites = c2c;
Log( LOG_DEBUG, "Added \"%s\" to invite list for \"%s\".", Pattern, Channel_Name( Chan ));
Log( LOG_DEBUG, "Added \"%s\" to invite list for \"%s\".", Mask, Channel_Name( Chan ));
return TRUE;
} /* Lists_AddInvited */
@ -200,6 +202,18 @@ Lists_DeleteChannel( CHANNEL *Chan )
} /* Lists_DeleteChannel */
GLOBAL CHAR *
Lists_MakeMask( CHAR *Pattern )
{
assert( Pattern );
/* Hier sollte aus einem "beliebigen" Pattern eine
* gueltige IRC-Mask erzeugt werden ... */
return Pattern;
} /* Lists_MakeMask */
LOCAL C2C *
New_C2C( CHAR *Mask, CHANNEL *Chan, BOOLEAN OnlyOnce )
{

View File

@ -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: lists.h,v 1.4 2002/07/15 16:35:21 alex Exp $
* $Id: lists.h,v 1.5 2002/08/26 23:39:22 alex Exp $
*
* lists.h: Verwaltung der "IRC-Listen": Ban, Invite, ... (Header)
*/
@ -23,12 +23,14 @@ GLOBAL VOID Lists_Init PARAMS(( VOID ));
GLOBAL VOID Lists_Exit PARAMS(( VOID ));
GLOBAL BOOLEAN Lists_CheckInvited PARAMS(( CLIENT *Client, CHANNEL *Chan ));
GLOBAL BOOLEAN Lists_AddInvited PARAMS(( CHAR *Pattern, CHANNEL *Chan, BOOLEAN OnlyOnce ));
GLOBAL BOOLEAN Lists_AddInvited PARAMS(( CHAR *Mask, CHANNEL *Chan, BOOLEAN OnlyOnce ));
GLOBAL BOOLEAN Lists_CheckBanned PARAMS(( CLIENT *Client, CHANNEL *Chan ));
GLOBAL VOID Lists_DeleteChannel PARAMS(( CHANNEL *Chan ));
GLOBAL CHAR *Lists_MakeMask PARAMS(( CHAR *Pattern ));
#endif

View File

@ -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: parse.c,v 1.35 2002/07/29 20:35:33 alex Exp $
* $Id: parse.c,v 1.36 2002/08/26 23:39:22 alex Exp $
*
* parse.c: Parsen der Client-Anfragen
*/
@ -348,6 +348,7 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
else if( strcasecmp( Req->command, "INVITE" ) == 0 ) return IRC_INVITE( client, Req );
else if( strcasecmp( Req->command, "KICK" ) == 0 ) return IRC_KICK( client, Req );
else if( strcasecmp( Req->command, "BAN" ) == 0 ) return IRC_BAN( client, Req );
else if( strcasecmp( Req->command, "CONNECT" ) == 0 ) return IRC_CONNECT( client, Req );
/* Unbekannter Befehl */
if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command );