Пример #1
0
	ModResult OnUserRegister(LocalUser* user)
	{
		ConfigTag* tag = user->MyClass->config;
		if (tag->getBool("requirectcp", true))
		{
			if (!ctcp.empty())
			{
				user->WriteServ("PRIVMSG %s :\001%s\001", user->nick.c_str(), ctcp.c_str());
			}
			ext.set(user, 1);
		}
		return MOD_RES_PASSTHRU;
	}
Пример #2
0
	ModResult OnUserRegister(LocalUser* user)
	{
		// Note this is their initial (unresolved) connect block
		ConfigTag* tag = user->MyClass->config;
		if (!tag->getBool("usesqlauth", true))
			return MOD_RES_PASSTHRU;

		if (!allowpattern.empty() && InspIRCd::Match(user->nick,allowpattern))
			return MOD_RES_PASSTHRU;

		if (pendingExt.get(user))
			return MOD_RES_PASSTHRU;

		if (!SQL)
		{
			ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s (SQL database not present)", user->GetFullRealHost().c_str());
			ServerInstance->Users->QuitUser(user, killreason);
			return MOD_RES_PASSTHRU;
		}

		pendingExt.set(user, AUTH_STATE_BUSY);

		ParamM userinfo;
		SQL->PopulateUserInfo(user, userinfo);
		userinfo["pass"] = user->password;

		HashProvider* md5 = ServerInstance->Modules->FindDataService<HashProvider>("hash/md5");
		if (md5)
			userinfo["md5pass"] = md5->hexsum(user->password);

		HashProvider* sha256 = ServerInstance->Modules->FindDataService<HashProvider>("hash/sha256");
		if (sha256)
			userinfo["sha256pass"] = sha256->hexsum(user->password);

		AuthQuery* authQuery = NULL;
		if (usebcrypt)
		{
			authQuery = new BCryptAuthQuery(this, user->uuid, user->password, pendingExt, verbose);
		}
		else
		{
			authQuery = new AuthQuery(this, user->uuid, pendingExt, verbose);
		}

		SQL->submit(authQuery, freeformquery, userinfo);

		return MOD_RES_PASSTHRU;
	}
Пример #3
0
	ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser* user, bool validated, const std::string &original_line)
	{
		if (command == "NOTICE" && !validated && parameters.size() > 1 && ext.get(user))
		{
			if (parameters[1].size() > 1 && parameters[1][0] == 0x1 && parameters[1].compare(1, ctcp.length(), ctcp) == 0)
			{
				ext.set(user, 0);
				if (!accepted.empty())
				{
					user->WriteServ("NOTICE " + user->nick + " :*** " + accepted);
				}
				return MOD_RES_DENY;
			}
		}
		return MOD_RES_PASSTHRU;
	}
Пример #4
0
	ModResult OnCheckReady(LocalUser* user)
	{
		if (ext.get(user))
		{
			if (!declined.empty())
			{
				ServerInstance->Users->QuitUser(user, declined);
			}
			if (ext.get(user) != 3)
			{
				ext.set(user, 3);
				ServerInstance->SNO->WriteGlobalSno('p', "Suspicious connection on port %d (class %s) from %s (%s) was blocked by m_requirectcp", user->GetServerPort(), user->MyClass->name.c_str(), user->GetFullRealHost().c_str(), user->GetIPString());
			}
			return MOD_RES_DENY;
		}
		return MOD_RES_PASSTHRU;
	}
Пример #5
0
	CmdResult Handle (const std::vector<std::string> &parameters, User *user)
	{
		std::string subcommand(parameters[0].length(), ' ');
		std::transform(parameters[0].begin(), parameters[0].end(), subcommand.begin(), ::toupper);

		if (subcommand == "REQ")
		{
			if (parameters.size() < 2)
				return CMD_FAILURE;

			CapEvent Data(creator, user, CapEvent::CAPEVENT_REQ);

			// tokenize the input into a nice list of requested caps
			std::string cap_;
			irc::spacesepstream cap_stream(parameters[1]);

			while (cap_stream.GetToken(cap_))
			{
				std::transform(cap_.begin(), cap_.end(), cap_.begin(), ::tolower);
				Data.wanted.push_back(cap_);
			}

			reghold.set(user, 1);
			FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));

			if (Data.ack.size() > 0)
			{
				std::string AckResult = irc::stringjoiner(Data.ack);
				user->WriteCommand("CAP", "ACK :" + AckResult);
			}

			if (Data.wanted.size() > 0)
			{
				std::string NakResult = irc::stringjoiner(Data.wanted);
				user->WriteCommand("CAP", "NAK :" + NakResult);
			}
		}
		else if (subcommand == "END")
		{
			reghold.set(user, 0);
		}
		else if ((subcommand == "LS") || (subcommand == "LIST"))
		{
			CapEvent Data(creator, user, subcommand == "LS" ? CapEvent::CAPEVENT_LS : CapEvent::CAPEVENT_LIST);

			reghold.set(user, 1);
			FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));

			std::string Result = irc::stringjoiner(Data.wanted);
			user->WriteCommand("CAP", subcommand + " :" + Result);
		}
		else if (subcommand == "CLEAR")
		{
			CapEvent Data(creator, user, CapEvent::CAPEVENT_CLEAR);

			reghold.set(user, 1);
			FOREACH_MOD_CUSTOM(capevprov, GenericCap, OnCapEvent, (Data));

			std::string Result = irc::stringjoiner(Data.ack);
			user->WriteCommand("CAP", "ACK :" + Result);
		}
		else
		{
			user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s :Invalid CAP subcommand", subcommand.c_str());
			return CMD_FAILURE;
		}

		return CMD_SUCCESS;
	}
Пример #6
0
	CmdResult Handle (const std::vector<std::string> &parameters, User *user)
	{
		irc::string subcommand = parameters[0].c_str();

		if (subcommand == "REQ")
		{
			if (parameters.size() < 2)
				return CMD_FAILURE;

			CapEvent Data(creator, user, CapEvent::CAPEVENT_REQ);

			// tokenize the input into a nice list of requested caps
			std::string cap_;
			irc::spacesepstream cap_stream(parameters[1]);

			while (cap_stream.GetToken(cap_))
			{
				Data.wanted.push_back(cap_);
			}

			reghold.set(user, 1);
			Data.Send();

			if (Data.ack.size() > 0)
			{
				std::string AckResult = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
				user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), AckResult.c_str());
			}

			if (Data.wanted.size() > 0)
			{
				std::string NakResult = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();
				user->WriteServ("CAP %s NAK :%s", user->nick.c_str(), NakResult.c_str());
			}
		}
		else if (subcommand == "END")
		{
			reghold.set(user, 0);
		}
		else if ((subcommand == "LS") || (subcommand == "LIST"))
		{
			CapEvent Data(creator, user, subcommand == "LS" ? CapEvent::CAPEVENT_LS : CapEvent::CAPEVENT_LIST);

			reghold.set(user, 1);
			Data.Send();

			std::string Result;
			if (Data.wanted.size() > 0)
				Result = irc::stringjoiner(" ", Data.wanted, 0, Data.wanted.size() - 1).GetJoined();

			user->WriteServ("CAP %s %s :%s", user->nick.c_str(), subcommand.c_str(), Result.c_str());
		}
		else if (subcommand == "CLEAR")
		{
			CapEvent Data(creator, user, CapEvent::CAPEVENT_CLEAR);

			reghold.set(user, 1);
			Data.Send();

			std::string Result;
			if (!Data.ack.empty())
				Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
			user->WriteServ("CAP %s ACK :%s", user->nick.c_str(), Result.c_str());
		}
		else
		{
			user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s %s :Invalid CAP subcommand", user->nick.c_str(), subcommand.c_str());
			return CMD_FAILURE;
		}

		return CMD_SUCCESS;
	}
Пример #7
0
void ModuleDelayJoin::OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& except)
{
	if (unjoined.set(memb, 0))
		populate(except, memb);
}
Пример #8
0
void ModuleDelayJoin::OnUserPart(Membership* memb, std::string &partmessage, CUList& except)
{
	if (unjoined.set(memb, 0))
		populate(except, memb);
}
Пример #9
0
void ModuleDelayJoin::OnUserJoin(Membership* memb, bool sync, bool created, CUList& except)
{
	if (memb->chan->IsModeSet(djm))
		unjoined.set(memb, 1);
}