]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-mode.c
New configuration option "NoZeroConf" to disable ZeroConf registration
[ngircd-alex.git] / src / ngircd / irc-mode.c
index cd470863aa2edea492a9e818cce5103c1d50af72..df464a7dba7efca0058cdede4d18ec8090a7eeea 100644 (file)
 
 #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
@@ -182,6 +185,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                                        ERR_NOPRIVILEGES_MSG,
                                                        Client_ID(Origin));
                                break;
+
                        case 'o': /* IRC operator (only unsettable!) */
                                if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
                                {
@@ -196,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 );
@@ -294,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;
@@ -311,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;
@@ -326,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;
@@ -758,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;