X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-mode.c;h=df464a7dba7efca0058cdede4d18ec8090a7eeea;hb=c135d0dded909e2e5780697c4066ad44a3f488c8;hp=d22d32f01acc3c82a787ecc375a6fe041cc57e39;hpb=9f58418765576950983b4a95c4f5f71f068f424f;p=ngircd-alex.git diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index d22d32f0..df464a7d 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -22,27 +22,30 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" #include "log.h" #include "parse.h" #include "messages.h" -#include "resolve.h" #include "conf.h" #include "exp.h" #include "irc-mode.h" -static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )); -static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )); +static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, + CLIENT *Target )); +static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, + CHANNEL *Channel )); -static bool Add_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)); -static bool Del_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)); +static bool Add_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Pattern)); +static bool Del_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Pattern)); -static bool Send_ListChange PARAMS(( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask )); +static bool Send_ListChange PARAMS((const char *Mode, CLIENT *Prefix, + CLIENT *Client, CHANNEL *Channel, const char *Mask)); GLOBAL bool @@ -172,6 +175,17 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ) else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin )); break; + case 'c': /* Receive connect notices + * (only settable by IRC operators!) */ + if(!set || Client_OperByMe(Origin) + || Client_Type(Client) == CLIENT_SERVER) + x[0] = 'c'; + else + ok = IRC_WriteStrClient(Origin, + ERR_NOPRIVILEGES_MSG, + Client_ID(Origin)); + break; + case 'o': /* IRC operator (only unsettable!) */ if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER )) { @@ -186,6 +200,15 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ) else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin )); break; + case 'x': /* Cloak hostname */ + if (Client_HasMode(Client, 'r')) + IRC_WriteStrClient(Origin, + ERR_RESTRICTED_MSG, + Client_ID(Origin)); + else + x[0] = 'x'; + break; + default: Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin )); if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr ); @@ -284,7 +307,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) { char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr; - bool connected, set, modeok = true, skiponce, use_servermode = false, retval; + bool connected, set, skiponce, retval, onchannel; + bool modeok = true, use_servermode = false; int mode_arg, arg_arg; CLIENT *client; long l; @@ -301,14 +325,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) /* Is the user allowed to change modes? */ if (Client_Type(Client) == CLIENT_USER) { /* Is the originating user on that channel? */ - if (!Channel_IsMemberOf(Channel, Origin)) - return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, - Client_ID(Origin), Channel_Name(Channel)); + onchannel = Channel_IsMemberOf(Channel, Origin); modeok = false; /* channel operator? */ - if (strchr(Channel_UserModes(Channel, Origin), 'o')) + if (onchannel && + strchr(Channel_UserModes(Channel, Origin), 'o')) { modeok = true; - else if (Conf_OperCanMode) { + } else if (Conf_OperCanMode) { /* IRC-Operators can use MODE as well */ if (Client_OperByMe(Origin)) { modeok = true; @@ -316,6 +339,10 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) use_servermode = true; /* Change Origin to Server */ } } + + if (!onchannel && !modeok) + return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, + Client_ID(Origin), Channel_Name(Channel)); } mode_arg = 1; @@ -748,7 +775,8 @@ Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const static bool -Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask ) +Send_ListChange(const char *Mode, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Mask) { bool ok;