ngircd

Free, portable and lightweight Internet Relay Chat server http://ngircd.barton.de/
Log | Files | Refs | README | LICENSE

commit 90ea23ab4fe3032824e22eb59bee305f35c4aae7
parent 6e7e744cc6c3d378ac9bace41586e4f32f456551
Author: Alexander Barton <alex@barton.de>
Date:   Sat,  1 Aug 2015 14:24:20 +0200

Merge pull request #214 from Flupsy/channel-mode-N

Channel mode N (users on this channel can't change their nick)
Diffstat:
Mdoc/Modes.txt | 1+
Msrc/ngircd/irc-login.c | 17+++++++++++++++++
Msrc/ngircd/irc-mode.c | 1+
Msrc/ngircd/messages.h | 1+
4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/doc/Modes.txt b/doc/Modes.txt @@ -56,6 +56,7 @@ users to lists (e.g. "invite list", "ban list"), others have parameters m 0.3.0 Channel is moderated, only "voiced" users can send messages. M 20 Only registered users (and IRC Ops) can send messages. n 0.3.0 Channel doesn't allow messages of users not being members. + N ?? Users can't change their nickname while on this channel. O 18 Only IRC operators are allowed to join this channel. P 0.5.0 Channel is "persistent". Q 20 Nobody can be kicked from the channel. diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c @@ -172,6 +172,7 @@ GLOBAL bool IRC_NICK( CLIENT *Client, REQUEST *Req ) { CLIENT *intr_c, *target, *c; + CHANNEL *chan; char *nick, *user, *hostname, *modes, *info; int token, hops; @@ -259,6 +260,22 @@ IRC_NICK( CLIENT *Client, REQUEST *Req ) Client_SetType( Client, CLIENT_GOTNICK ); } else { /* Nickname change */ + + /* Check that the user isn't on any channels set +N */ + if(Client_Type(Client) == CLIENT_USER && + !Client_HasMode(Client, 'o')) { + chan = Channel_First(); + while (chan) { + if(Channel_IsMemberOf(chan, Client) && + Channel_HasMode(chan, 'N')) + return IRC_WriteErrClient(Client, + ERR_NONICKCHANGE_MSG, + Client_ID(Client), + Channel_Name(chan)); + chan = Channel_Next(chan); + } + } + Change_Nick(Client, target, Req->argv[0], Client_Type(Client) == CLIENT_USER ? true : false); IRC_SetPenalty(target, 2); diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c @@ -580,6 +580,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) case 'M': /* Only identified nicks can write */ case 'm': /* Moderated */ case 'n': /* Only members can write */ + case 'N': /* Can't change nick while on this channel */ case 'Q': /* No kicks */ case 't': /* Topic locked */ if(is_oper || is_machine || is_owner || diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h @@ -127,6 +127,7 @@ #define ERR_USERONCHANNEL_MSG "443 %s %s %s :is already on channel" #define ERR_SUMMONDISABLED_MSG "445 %s :SUMMON has been disabled" #define ERR_USERSDISABLED_MSG "446 %s :USERS has been disabled" +#define ERR_NONICKCHANGE_MSG "447 %s :Cannot change nickname while on %s(+N)" #define ERR_NOTREGISTERED_MSG "451 %s :Connection not registered" #define ERR_NOTREGISTEREDSERVER_MSG "451 %s :Connection not registered as server link" #define ERR_NEEDMOREPARAMS_MSG "461 %s %s :Syntax error"