]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix m_alias not initialising 'active' before use.
[user/henk/code/inspircd.git] / src / users.cpp
index e17c8cd79417764df5bc883231aa2b811c64e229..f11a7a38079e43d3fba28c9fc914f1ce0fcc3deb 100644 (file)
@@ -357,10 +357,12 @@ CullResult FakeUser::cull()
 void User::Oper(OperInfo* info)
 {
        ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
-       if (this->IsModeSet(opermh))
-               this->UnOper();
-
-       this->SetMode(opermh, true);
+       if (opermh)
+       {
+               if (this->IsModeSet(opermh))
+                       this->UnOper();
+               this->SetMode(opermh, true);
+       }
        this->oper = info;
 
        LocalUser* localuser = IS_LOCAL(this);
@@ -474,7 +476,8 @@ void User::UnOper()
        stdalgo::vector::swaperase(ServerInstance->Users->all_opers, this);
 
        ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
-       this->SetMode(opermh, false);
+       if (opermh)
+               this->SetMode(opermh, false);
        FOREACH_MOD(OnPostDeoper, (this));
 }
 
@@ -557,45 +560,15 @@ void LocalUser::FullConnect()
        if (quitting)
                return;
 
-       this->WriteNumeric(RPL_WELCOME, InspIRCd::Format("Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str()));
-       this->WriteNumeric(RPL_YOURHOSTIS, InspIRCd::Format("Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH));
-       this->WriteNumeric(RPL_SERVERCREATED, InspIRCd::TimeString(ServerInstance->startup_time, "This server was created %H:%M:%S %b %d %Y"));
-
-       const TR1NS::array<std::string, 3>& modelist = ServerInstance->Modes->GetModeListFor004Numeric();
-       this->WriteNumeric(RPL_SERVERVERSION, ServerInstance->Config->ServerName, INSPIRCD_BRANCH, modelist[0], modelist[1], modelist[2]);
-
-       ServerInstance->ISupport.SendTo(this);
-
-       /* Now registered */
-       if (ServerInstance->Users->unregistered_count)
-               ServerInstance->Users->unregistered_count--;
-
-       /* Trigger MOTD and LUSERS output, give modules a chance too */
-       ModResult MOD_RESULT;
-       std::string command("LUSERS");
-       CommandBase::Params parameters;
-       FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
-       if (!MOD_RESULT)
-               ServerInstance->Parser.CallHandler(command, parameters, this);
-
-       MOD_RESULT = MOD_RES_PASSTHRU;
-       command = "MOTD";
-       FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
-       if (!MOD_RESULT)
-               ServerInstance->Parser.CallHandler(command, parameters, this);
-
-       if (ServerInstance->Config->RawLog)
-       {
-               ClientProtocol::Messages::Privmsg rawlogmsg(ServerInstance->FakeClient, this, "*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
-               this->Send(ServerInstance->GetRFCEvents().privmsg, rawlogmsg);
-       }
-
        /*
         * We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
         * for a user that doesn't exist yet.
         */
        FOREACH_MOD(OnUserConnect, (this));
 
+       /* Now registered */
+       if (ServerInstance->Users->unregistered_count)
+               ServerInstance->Users->unregistered_count--;
        this->registered = REG_ALL;
 
        FOREACH_MOD(OnPostConnect, (this));
@@ -752,21 +725,31 @@ irc::sockets::cidr_mask User::GetCIDRMask()
 
 bool User::SetClientIP(const std::string& address, bool recheck_eline)
 {
-       this->InvalidateCache();
-       return irc::sockets::aptosa(address, 0, client_sa);
+       irc::sockets::sockaddrs sa;
+       if (!irc::sockets::aptosa(address, client_sa.port(), sa))
+               return false;
+
+       User::SetClientIP(sa, recheck_eline);
+       return true;
 }
 
 void User::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline)
 {
-       this->InvalidateCache();
+       const std::string oldip(GetIPString());
        memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs));
+       this->InvalidateCache();
+
+       // If the users hostname was their IP then update it.
+       if (GetRealHost() == oldip)
+               ChangeRealHost(GetIPString(), false);
+       if (GetDisplayedHost() == oldip)
+               ChangeDisplayedHost(GetIPString());
 }
 
 bool LocalUser::SetClientIP(const std::string& address, bool recheck_eline)
 {
        irc::sockets::sockaddrs sa;
-       if (!irc::sockets::aptosa(address, 0, sa))
-               // Invalid
+       if (!irc::sockets::aptosa(address, client_sa.port(), sa))
                return false;
 
        LocalUser::SetClientIP(sa, recheck_eline);
@@ -1181,8 +1164,6 @@ void User::PurgeEmptyChannels()
                ++i;
                c->DelUser(this);
        }
-
-       this->UnOper();
 }
 
 void User::WriteNotice(const std::string& text)