mirror of
https://github.com/osmarks/ngircd.git
synced 2025-01-31 17:49:11 +00:00
Implement user mode 'C': require "same channel" to send message
If the target user of a PRIVMSG or NOTICE command has the user mode 'C' set, it is required that both sender and receiver are on the same channel. This prevents private flooding by completely unknown clients.
This commit is contained in:
parent
4d0069c3a8
commit
1f4711a547
@ -23,6 +23,7 @@ channels he is using at the moment.
|
|||||||
|
|
||||||
a 0.3.0 User is away.
|
a 0.3.0 User is away.
|
||||||
c 17 IRC operator wants to receive connect/disconnect NOTICEs.
|
c 17 IRC operator wants to receive connect/disconnect NOTICEs.
|
||||||
|
C 19 Only users that share a channel are allowed to send messages.
|
||||||
i 0.0.1 User is "invisible".
|
i 0.0.1 User is "invisible".
|
||||||
o 0.0.1 User is IRC operator.
|
o 0.0.1 User is IRC operator.
|
||||||
r 0.0.1 User is restricted.
|
r 0.0.1 User is restricted.
|
||||||
|
@ -158,7 +158,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Supported user modes. */
|
/** Supported user modes. */
|
||||||
#define USERMODES "aciorRswx"
|
#define USERMODES "acCiorRswx"
|
||||||
|
|
||||||
/** Supported channel modes. */
|
/** Supported channel modes. */
|
||||||
#define CHANMODES "biIklmnoOPRstvz"
|
#define CHANMODES "biIklmnoOPRstvz"
|
||||||
|
@ -214,6 +214,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
|
|||||||
/* Validate modes */
|
/* Validate modes */
|
||||||
x[0] = '\0';
|
x[0] = '\0';
|
||||||
switch (*mode_ptr) {
|
switch (*mode_ptr) {
|
||||||
|
case 'C': /* Only messages from clients sharing a channel */
|
||||||
case 'i': /* Invisible */
|
case 'i': /* Invisible */
|
||||||
case 's': /* Server messages */
|
case 's': /* Server messages */
|
||||||
case 'w': /* Wallops messages */
|
case 'w': /* Wallops messages */
|
||||||
|
@ -349,6 +349,7 @@ static bool
|
|||||||
Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
||||||
{
|
{
|
||||||
CLIENT *cl, *from;
|
CLIENT *cl, *from;
|
||||||
|
CL2CHAN *cl2chan;
|
||||||
CHANNEL *chan;
|
CHANNEL *chan;
|
||||||
char *currentTarget = Req->argv[0];
|
char *currentTarget = Req->argv[0];
|
||||||
char *lastCurrentTarget = NULL;
|
char *lastCurrentTarget = NULL;
|
||||||
@ -485,6 +486,23 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (Client_HasMode(cl, 'C')) {
|
||||||
|
cl2chan = Channel_FirstChannelOf(cl);
|
||||||
|
while (cl2chan) {
|
||||||
|
chan = Channel_GetChannel(cl2chan);
|
||||||
|
if (Channel_IsMemberOf(chan, from))
|
||||||
|
break;
|
||||||
|
cl2chan = Channel_NextChannelOf(cl, cl2chan);
|
||||||
|
}
|
||||||
|
if (!cl2chan) {
|
||||||
|
if (SendErrors && !IRC_WriteStrClient(
|
||||||
|
from, ERR_NOTONSAMECHANNEL_MSG,
|
||||||
|
Client_ID(from), Client_ID(cl)))
|
||||||
|
return DISCONNECTED;
|
||||||
|
goto send_next_target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SendErrors && (Client_Type(Client) != CLIENT_SERVER)
|
if (SendErrors && (Client_Type(Client) != CLIENT_SERVER)
|
||||||
&& strchr(Client_Modes(cl), 'a')) {
|
&& strchr(Client_Modes(cl), 'a')) {
|
||||||
/* Target is away */
|
/* Target is away */
|
||||||
@ -522,6 +540,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
|
|||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send_next_target:
|
||||||
currentTarget = strtok_r(NULL, ",", &lastCurrentTarget);
|
currentTarget = strtok_r(NULL, ",", &lastCurrentTarget);
|
||||||
if (currentTarget)
|
if (currentTarget)
|
||||||
Conn_SetPenalty(Client_Conn(Client), 1);
|
Conn_SetPenalty(Client_Conn(Client), 1);
|
||||||
|
@ -134,6 +134,7 @@
|
|||||||
#define ERR_CANTKILLSERVER_MSG "483 %s :You can't kill a server!"
|
#define ERR_CANTKILLSERVER_MSG "483 %s :You can't kill a server!"
|
||||||
#define ERR_RESTRICTED_MSG "484 %s :Your connection is restricted"
|
#define ERR_RESTRICTED_MSG "484 %s :Your connection is restricted"
|
||||||
#define ERR_NOOPERHOST_MSG "491 %s :Not configured for your host"
|
#define ERR_NOOPERHOST_MSG "491 %s :Not configured for your host"
|
||||||
|
#define ERR_NOTONSAMECHANNEL_MSG "493 %s :You must share a common channel with %s"
|
||||||
|
|
||||||
#define ERR_UMODEUNKNOWNFLAG_MSG "501 %s :Unknown mode"
|
#define ERR_UMODEUNKNOWNFLAG_MSG "501 %s :Unknown mode"
|
||||||
#define ERR_UMODEUNKNOWNFLAG2_MSG "501 %s :Unknown mode \"%c%c\""
|
#define ERR_UMODEUNKNOWNFLAG2_MSG "501 %s :Unknown mode \"%c%c\""
|
||||||
|
Loading…
Reference in New Issue
Block a user