X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_cloaking.cpp;h=b9ff085c3ebdc488894e4db053b3ef64cddceb98;hb=a0f7d012791d79b67b56b62415f7901d5e48870f;hp=e5f912c95ffa30cc8ea42b0709fb43261ead210f;hpb=96cc8bf4813877724d011531da1923aa457d8542;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index e5f912c95..b9ff085c3 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -137,7 +137,7 @@ class CommandCloak : public Command syntax = ""; } - CmdResult Handle(const std::vector& parameters, User* user) CXX11_OVERRIDE; + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE; }; class ModuleCloaking : public Module @@ -223,7 +223,7 @@ class ModuleCloaking : public Module size_t hop1, hop2, hop3; size_t len1, len2; std::string rv; - if (ip.sa.sa_family == AF_INET6) + if (ip.family() == AF_INET6) { bindata = std::string((const char*)ip.in6.sin6_addr.s6_addr, 16); hop1 = 8; @@ -267,7 +267,7 @@ class ModuleCloaking : public Module } else { - if (ip.sa.sa_family == AF_INET6) + if (ip.family() == AF_INET6) { rv.append(InspIRCd::Format(".%02x%02x.%02x%02x%s", ip.in6.sin6_addr.s6_addr[2], ip.in6.sin6_addr.s6_addr[3], @@ -313,7 +313,13 @@ class ModuleCloaking : public Module if (u->IsModeSet(cu) && !cu.active) { u->SetMode(cu, false); - u->WriteCommand("MODE", "-" + ConvToStr(cu.GetModeChar())); + + if (!IS_LOCAL(u)) + return; + Modes::ChangeList modechangelist; + modechangelist.push_remove(&cu); + ClientProtocol::Events::Mode modeevent(ServerInstance->FakeClient, NULL, u, modechangelist); + static_cast(u)->Send(modeevent); } cu.active = false; } @@ -350,12 +356,12 @@ class ModuleCloaking : public Module suffix = tag->getString("suffix", ".IP"); std::string modestr = tag->getString("mode"); - if (modestr == "half") + if (stdalgo::string::equalsci(modestr, "half")) { mode = MODE_HALF_CLOAK; - domainparts = tag->getInt("domainparts", 3, 1, 10); + domainparts = tag->getUInt("domainparts", 3, 1, 10); } - else if (modestr == "full") + else if (stdalgo::string::equalsci(modestr, "full")) mode = MODE_OPAQUE; else throw ModuleException("Bad value for ; must be half or full"); @@ -395,11 +401,15 @@ class ModuleCloaking : public Module if (cloak) return; + // TODO: decide how we are going to cloak AF_UNIX hostnames. + if (dest->client_sa.family() != AF_INET && dest->client_sa.family() != AF_INET6) + return; + cu.ext.set(dest, GenCloak(dest->client_sa, dest->GetIPString(), dest->GetRealHost())); } }; -CmdResult CommandCloak::Handle(const std::vector ¶meters, User *user) +CmdResult CommandCloak::Handle(User* user, const Params& parameters) { ModuleCloaking* mod = (ModuleCloaking*)(Module*)creator; irc::sockets::sockaddrs sa;