X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=f11a7a38079e43d3fba28c9fc914f1ce0fcc3deb;hb=f4041a13c3894e282fb34010f3373d1950136a8c;hp=1ddd3ca0ef99864d0c1da9a87b8ede2654be3c96;hpb=b5bc17fba34044097844263641c0f612db75d466;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 1ddd3ca0e..f11a7a380 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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)); } @@ -722,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); @@ -1151,8 +1164,6 @@ void User::PurgeEmptyChannels() ++i; c->DelUser(this); } - - this->UnOper(); } void User::WriteNotice(const std::string& text)