Ejemplo n.º 1
0
void bahamut::senders::Akill::Send(User* u, XLine* x)
{
	if (x->IsRegex() || x->HasNickOrReal())
	{
		if (!u)
		{
			/* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */
			for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
				if (x->GetManager()->Check(it->second, x))
					this->Send(it->second, x);
			return;
		}

		XLine *old = x;

		if (old->GetManager()->HasEntry("*@" + u->host))
			return;

		/* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
		x = Serialize::New<XLine *>();
		x->SetMask("*@" + u->host);
		x->SetBy(old->GetBy());
		x->SetExpires(old->GetExpires());
		x->SetReason(old->GetReason());
		x->SetID(old->GetID());
		old->GetManager()->AddXLine(x);

		Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask();
	}

	/* ZLine if we can instead */
	if (x->GetUser() == "*")
	{
		cidr a(x->GetHost());
		if (a.valid())
		{
			IRCD->Send<messages::SZLine>(u, x);
			return;
		}
	}

	// Calculate the time left before this would expire, capping it at 2 days
	time_t timeleft = x->GetExpires() - Anope::CurTime;
	if (timeleft > 172800)
		timeleft = 172800;

	Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason());
}
Ejemplo n.º 2
0
	void SendAkill(User *u, XLine *x) override
	{
		if (x->IsRegex() || x->HasNickOrReal())
		{
			if (!u)
			{
				/*
				 * No user (this akill was just added), and contains nick and/or realname.
				 * Find users that match and ban them.
				 */
				for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
					if (x->GetManager()->Check(it->second, x))
						this->SendAkill(it->second, x);

				return;
			}

			XLine *old = x;

			if (old->GetManager()->HasEntry("*@" + u->host))
				return;

			/* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
			XLine *xl = Serialize::New<XLine *>();
			xl->SetMask("*@" + u->host);
			xl->SetBy(old->GetBy());
			xl->SetExpires(old->GetExpires());
			xl->SetReason(old->GetReason());
			xl->SetID(old->GetID());

			old->GetManager()->AddXLine(xl);
			x = xl;

			Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#"
					<< u->realname << " matches " << old->GetMask();
		}

		/* Calculate the time left before this would expire, capping it at 2 days */
		time_t timeleft = x->GetExpires() - Anope::CurTime;

		if (timeleft > 172800 || !x->GetExpires())
			timeleft = 172800;

		Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason());
	}