]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cmd_oper.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / cmd_oper.cpp
index 2681da13e9be09fd5133f285ed0f473bf97af583..f695c44f858b6fdc4b468d5f4a6b012e63f982fc 100644 (file)
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
 #include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
 #include <sstream>
 #include <vector>
-#include <deque>
+#include "inspircd_config.h"
+#include "configreader.h"
+#include "typedefs.h"
 #include "users.h"
-#include "ctables.h"
 #include "globals.h"
 #include "modules.h"
 #include "dynamic.h"
@@ -41,34 +30,27 @@ using namespace std;
 #include "mode.h"
 #include "xline.h"
 #include "inspstring.h"
-#include "dnsqueue.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "socketengine.h"
-#include "typedefs.h"
+
 #include "command_parse.h"
-#include "cmd_oper.h"
+#include "commands/cmd_oper.h"
 
 extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
 extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
 extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
 
-bool OneOfMatches(const char* host, const char* hostlist)
+bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
 {
        std::stringstream hl(hostlist);
        std::string xhost;
        while (hl >> xhost)
        {
                log(DEBUG,"Oper: Matching host %s",xhost.c_str());
-               if (match(host,xhost.c_str()))
+               if (match(host,xhost.c_str()) || match(ip,xhost.c_str(),true))
                {
                        return true;
                }
@@ -76,7 +58,7 @@ bool OneOfMatches(const char* host, const char* hostlist)
        return false;
 }
 
-void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
+void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
 {
        char LoginName[MAXBUF];
        char Password[MAXBUF];
@@ -84,11 +66,13 @@ void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
        char TypeName[MAXBUF];
        char HostName[MAXBUF];
        char TheHost[MAXBUF];
+       char TheIP[MAXBUF];
        int j;
        bool found = false;
        bool fail2 = false;
 
        snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host);
+       snprintf(TheIP, MAXBUF,"%s@%s",user->ident,user->GetIPString());
 
        for (int i = 0; i < Config->ConfValueEnum(Config->config_data, "oper"); i++)
        {
@@ -97,7 +81,7 @@ void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
                Config->ConfValue(Config->config_data, "oper", "type", i, OperType, MAXBUF);
                Config->ConfValue(Config->config_data, "oper", "host", i, HostName, MAXBUF);
 
-               if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (OneOfMatches(TheHost,HostName)))
+               if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (OneOfMatches(TheHost,TheIP,HostName)))
                {
                        fail2 = true;
                        for (j =0; j < Config->ConfValueEnum(Config->config_data, "type"); j++)
@@ -132,9 +116,9 @@ void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
                /* correct oper credentials */
                WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
                WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
-               if (!strchr(user->modes,'o'))
+               if (!user->modes[UM_OPERATOR])
                {
-                       strcat(user->modes,"o");
+                       user->modes[UM_OPERATOR] = 1;
                        WriteServ(user->fd,"MODE %s :+o",user->nick);
                        FOREACH_MOD(I_OnOper,OnOper(user,OperType));
                        log(DEFAULT,"OPER: %s!%s@%s opered as type: %s",user->nick,user->ident,user->host,OperType);