Ejemplo n.º 1
0
	EventReturn OnLoadDatabase() override
	{
		if (!redis)
			return EVENT_STOP;

		const std::map<Anope::string, Serialize::TypeBase *> &types = Serialize::TypeBase::GetTypes();
		for (const std::pair<Anope::string, Serialize::TypeBase *> &p : types)
			this->OnSerializeTypeCreate(p.second);

		while (redis->BlockAndProcess());

		redis->Subscribe(&this->sl, "anope");

		return EVENT_STOP;
	}
Ejemplo n.º 2
0
	void DoDel(CommandSource &source, const std::vector<Anope::string> &params)
	{
		const Anope::string nick = params.size() > 1 ? params[1] : "";
		if (nick.empty())
		{
			this->OnSyntaxError(source, "DEL");
			return;
		}

		Anope::string mask = RealMask(nick);
		if (mask.empty())
		{
			source.Reply(_("Mask must be in the form \037user\037@\037host\037."));
			return;
		}

		Ignore *ign = ignore_service->Find(mask);
		if (!ign)
		{
			source.Reply(_("\002{0}\002 not found on ignore list."), mask);	
			return;
		}

		if (Anope::ReadOnly)
			source.Reply(_("Services are in read-only mode. Any changes made may not persist."));

		Log(LOG_ADMIN, source, this) << "to remove an ignore on " << mask;
		source.Reply(_("\002{0}\002 will no longer be ignored."), mask);
		ign->Delete();
	}
Ejemplo n.º 3
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		if (Anope::ReadOnly)
		{
			source.Reply(_("Services are in read-only mode."));
			return;
		}

		const Anope::string &nick = params[0];
		NickServ::Nick *na = NickServ::FindNick(nick);

		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		HostRequest *req = na->GetExt<HostRequest>("hostrequest");
		if (!req)
		{
			source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick());
			return;
		}

		na->SetVhost(req->GetIdent(), req->GetHost(), source.GetNick(), req->GetTime());
		EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, na);

		if (Config->GetModule(this->GetOwner())->Get<bool>("memouser") && memoserv)
			memoserv->Send(source.service->nick, na->GetNick(), _("[auto memo] Your requested vHost has been approved."), true);

		source.Reply(_("Vhost for \002{0}\002 has been activated."), na->GetNick());
		Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " for vhost " << (!req->GetIdent().empty() ? req->GetIdent() + "@" : "") << req->GetHost();
		req->Delete();
	}
Ejemplo n.º 4
0
	EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
	{
		if (!md5)
			return EVENT_CONTINUE;

		Encryption::Context *context = md5->CreateContext();
		context->Update(reinterpret_cast<const unsigned char *>(src.c_str()), src.length());
		context->Finalize();

		Encryption::Hash hash = context->GetFinalizedHash();

		char digest[32], digest2[16];
		memset(digest, 0, sizeof(digest));
		if (hash.second > sizeof(digest))
			throw CoreException("Hash too large");
		memcpy(digest, hash.first, hash.second);

		for (int i = 0; i < 32; i += 2)
			digest2[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]);

		Anope::string buf = "oldmd5:" + Anope::Hex(digest2, sizeof(digest2));

		Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]";
		dest = buf;
		delete context;
		return EVENT_ALLOW;
	}
Ejemplo n.º 5
0
	void DoStatsHash(CommandSource &source)
	{
		size_t entries, buckets, max_chain;

		GetHashStats(UserListByNick, entries, buckets, max_chain);
		source.Reply(_("Users (nick): {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);

		if (!UserListByUID.empty())
		{
			GetHashStats(UserListByUID, entries, buckets, max_chain);
			source.Reply(_("Users (uid): {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);
		}

		GetHashStats(ChannelList, entries, buckets, max_chain);
		source.Reply(_("Channels: {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);

		GetHashStats(ChanServ::service->GetChannels(), entries, buckets, max_chain);
		source.Reply(_("Registered channels: {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);

		GetHashStats(NickServ::service->GetNickMap(), entries, buckets, max_chain);
		source.Reply(_("Registered nicknames: {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);

		GetHashStats(NickServ::service->GetAccountMap(), entries, buckets, max_chain);
		source.Reply(_("Registered nick groups: {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);

		if (session_service)
		{
			GetHashStats(session_service->GetSessions(), entries, buckets, max_chain);
			source.Reply(_("Sessions: {0} entries, {1} buckets, longest chain is {2}"), entries, buckets, max_chain);
		}
	}
Ejemplo n.º 6
0
	EventReturn OnSerializeSet(Serialize::Object *object, Serialize::FieldBase *field, const Anope::string &value) override
	{
		std::vector<Anope::string> args;

		redis->StartTransaction();

		const Anope::string &old = field->SerializeToString(object);
		args = { "SREM", "lookup:" + object->GetSerializableType()->GetName() + ":" + field->serialize_name + ":" + old, stringify(object->id) };
		redis->SendCommand(nullptr, args);

		// add object to type set
		args = { "SADD", "ids:" + object->GetSerializableType()->GetName(), stringify(object->id) };
		redis->SendCommand(nullptr, args);

		// add key to key set
		args = { "SADD", "keys:" + stringify(object->id), field->serialize_name };
		redis->SendCommand(nullptr, args);

		// set value
		args = { "SET", "values:" + stringify(object->id) + ":" + field->serialize_name, value };
		redis->SendCommand(nullptr, args);

		// lookup
		args = { "SADD", "lookup:" + object->GetSerializableType()->GetName() + ":" + field->serialize_name + ":" + value, stringify(object->id) };
		redis->SendCommand(nullptr, args);

		redis->CommitTransaction();

		return EVENT_CONTINUE;
	}
Ejemplo n.º 7
0
	EventReturn OnSerializeUnset(Serialize::Object *object, Serialize::FieldBase *field) override
	{
		std::vector<Anope::string> args;

		redis->StartTransaction();

		const Anope::string &old = field->SerializeToString(object);
		args = { "SREM", "lookup:" + object->GetSerializableType()->GetName() + ":" + field->serialize_name + ":" + old, stringify(object->id) };
		redis->SendCommand(nullptr, args);

		// remove field from set
		args = { "SREM", "keys:" + stringify(object->id), field->serialize_name };
		redis->SendCommand(nullptr, args);

		redis->CommitTransaction();

		return EVENT_CONTINUE;
	}
Ejemplo n.º 8
0
    ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
    {
        me = this;

        if (!xmlrpc)
            throw ModuleException("Unable to find xmlrpc reference, is m_xmlrpc loaded?");

        xmlrpc->Register(&stats);
    }
bool MiningBundleActivator::addingService( const ServiceReference& ref )
{
    if ( ref.getServiceName() == "IndexSearchService" )
    {
        Properties props = ref.getServiceProperties();
        if ( props.get( "collection" ) == config_->collectionName_)
        {
            IndexSearchService* service = reinterpret_cast<IndexSearchService*> ( const_cast<IService*>(ref.getService()) );
            cout << "[MiningBundleActivator#addingService] Calling IndexSearchService..." << endl;
            currentCollectionDataName_ = service->bundleConfig_->collPath_.getCurrCollectionDir();
            miningManager_ = createMiningManager_(service);
            if (!miningManager_)
            {
                cerr << "error: failed in creating MiningManager" << endl;
                return false;
            }
            searchService_ = new MiningSearchService;
            searchService_->bundleConfig_ = config_;
            searchService_->miningManager_ = miningManager_;
            searchService_->searchAggregator_ = service->searchAggregator_;
            searchService_->ro_searchAggregator_ = service->ro_searchAggregator_;
            searchService_->searchWorker_ = service->searchWorker_;

            taskService_ = new MiningTaskService(config_);
            taskService_->miningManager_ = miningManager_;

            Properties props;
            props.put( "collection", config_->collectionName_);
            searchServiceReg_ = context_->registerService( "MiningSearchService", searchService_, props );
            taskServiceReg_ = context_->registerService( "MiningTaskService", taskService_, props );
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }

}
Ejemplo n.º 10
0
	SQL::Result RunQuery(const SQL::Query &query)
	{
		if (!this->sql)
			throw SQL::Exception("Unable to locate SQL reference, is m_mysql loaded and configured correctly?");

		SQL::Result res = sql->RunQuery(query);
		if (!res.GetError().empty())
			throw SQL::Exception(res.GetError());
		return res;
	}
Ejemplo n.º 11
0
	void OnChannelSync(Channel *c) override
	{
		if (!c->ci || !mlocks)
			return;

		if (use_server_side_mlock && Servers::Capab.count("MLOCK") > 0)
		{
			Anope::string modes = mlocks->GetMLockAsString(c->ci, false).replace_all_cs("+", "").replace_all_cs("-", "");
			Uplink::Send(Me, "MLOCK", c->creation_time, c->ci->GetName(), modes);
		}
	}
Ejemplo n.º 12
0
	void OnSerializableDelete(Serialize::Object *obj) override
	{
		std::vector<Anope::string> args;

		redis->StartTransaction();

		for (Serialize::FieldBase *field : obj->GetSerializableType()->GetFields())
		{
			Anope::string value = field->SerializeToString(obj);

			args = { "SREM", "lookup:" + obj->GetSerializableType()->GetName() + ":" + field->serialize_name + ":" + value, stringify(obj->id) };
			redis->SendCommand(nullptr, args);

			args = { "DEL", "values:" + stringify(obj->id) + ":" + field->serialize_name };
			redis->SendCommand(nullptr, args);

			args = { "SREM", "keys:" + stringify(obj->id), field->serialize_name };
			redis->SendCommand(nullptr, args);
		}

		args = { "SREM", "ids:" + obj->GetSerializableType()->GetName(), stringify(obj->id) };
		redis->SendCommand(nullptr, args);

		redis->CommitTransaction();
	}
Ejemplo n.º 13
0
	EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) override
	{
		if (!mlocks)
			return EVENT_CONTINUE;

		ChannelMode *cm = ModeManager::FindChannelModeByName(lock->GetName());
		if (use_server_side_mlock && cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
		{
			Anope::string modes = mlocks->GetMLockAsString(ci, false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
			Uplink::Send(Me, "MLOCK", ci->c->creation_time, ci->GetName(), modes);
		}

		return EVENT_CONTINUE;
	}
Ejemplo n.º 14
0
	void OnUserNickChange(User *u)
	{
		if (u->HasMode("OPER"))
			return;

		ForbidData *d = fs->FindForbid(u->nick, FT_NICK);
		if (d != NULL)
		{
			ServiceBot *bi = Config->GetClient("NickServ");
			if (!bi)
				bi = Config->GetClient("OperServ");
			if (bi)
				u->SendMessage(bi, _("This nickname has been forbidden: \002{0}\002"), d->GetReason());
			if (NickServ::service)
				NickServ::service->Collide(u, NULL);
		}
	}
Ejemplo n.º 15
0
Archivo: log.cpp Proyecto: Robby-/anope
	void OnLog(Logger *logger) override
	{
		User *user = logger->GetUser();
		ChanServ::Channel *channel = logger->GetCi();
		Command *command = logger->GetCommand();
		CommandSource *source = logger->GetSource();

		if (logger->GetType() != LogType::COMMAND || user == nullptr || command == nullptr || channel == nullptr || !Me || !Me->IsSynced())
			return;

		Channel *c = channel->GetChannel();

		for (LogSetting *log : channel->GetRefs<LogSetting *>())
		{
			/* wrong command */
			if (log->GetServiceName() != command->GetName())
				continue;

			/* if a command name is given check the service and the command */
			if (!log->GetCommandName().empty())
			{
				/* wrong service (only check if not a fantasy command, though) */
				if (!source->c && log->GetCommandService() != source->service->nick)
					continue;

				if (!log->GetCommandName().equals_ci(source->GetCommand()))
					continue;
			}

			const Anope::string &buffer = logger->GetMaskedMessage();

			if (log->GetMethod().equals_ci("MEMO") && memoserv && channel->WhoSends() != NULL)
				memoserv->Send(channel->WhoSends()->nick, channel->GetName(), buffer, true);
			else if (source->c)
				/* Sending a channel message or notice in response to a fantasy command */;
			else if (log->GetMethod().equals_ci("MESSAGE") && c)
			{
				IRCD->SendPrivmsg(channel->WhoSends(), log->GetExtra() + c->name, "{0}", buffer);
#warning "fix idletimes"
				//l->ci->WhoSends()->lastmsg = Anope::CurTime;
			}
			else if (log->GetMethod().equals_ci("NOTICE") && c)
				IRCD->SendNotice(channel->WhoSends(), log->GetExtra() + c->name, "{0}", buffer);
		}
	}
Ejemplo n.º 16
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		if (Anope::ReadOnly)
		{
			source.Reply(_("Services are in read-only mode."));
			return;
		}

		const Anope::string &nick = params[0];
		const Anope::string &reason = params.size() > 1 ? params[1] : "";

		NickServ::Nick *na = NickServ::FindNick(nick);
		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		HostRequest *req = na->GetExt<HostRequest>("hostrequest");
		if (!req)
		{
			source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick());
			return;
		}

		req->Delete();

		if (Config->GetModule(this->GetOwner())->Get<bool>("memouser") && memoserv)
		{
			Anope::string message;
			if (!reason.empty())
				message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
			else
				message = _("[auto memo] Your requested vHost has been rejected.");

			memoserv->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
		}

		source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->GetNick());
		Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")";
	}
Ejemplo n.º 17
0
	void SendMemos(CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost)
	{
		Anope::string host;

		if (!vIdent.empty())
			host = vIdent + "@" + vHost;
		else
			host = vHost;

		if (Config->GetModule(GetOwner())->Get<bool>("memooper") && memoserv)
			for (Oper *o : Serialize::GetObjects<Oper *>()) 
			{
				NickServ::Nick *na = NickServ::FindNick(o->GetName());
				if (!na)
					continue;

				Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str());

				memoserv->Send(source.service->nick, na->GetNick(), message, true);
			}
	}
Ejemplo n.º 18
0
	void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); }
Ejemplo n.º 19
0
	void OnSerializeTypeCreate(Serialize::TypeBase *sb)
	{
		std::vector<Anope::string> args = { "SMEMBERS", "ids:" + sb->GetName() };

		redis->SendCommand(new TypeLoader(this, sb), args);
	}
Ejemplo n.º 20
0
	bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); }
Ejemplo n.º 21
0
	~ModuleXMLRPC()
	{
		if (httpref)
			httpref->UnregisterPage(&xmlrpcinterface);
	}
Ejemplo n.º 22
0
	void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendModeInternal(source, u, buf); }
Ejemplo n.º 23
0
	void SendChannel(Channel *c) override { hybrid->SendChannel(c); }
Ejemplo n.º 24
0
	void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); }
Ejemplo n.º 25
0
	void SendServer(const Server *server) override { hybrid->SendServer(server); }
Ejemplo n.º 26
0
	void SendSQLineDel(XLine *x) override { hybrid->SendSQLineDel(x); }
Ejemplo n.º 27
0
	void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); }
Ejemplo n.º 28
0
	void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); }
Ejemplo n.º 29
0
	void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); }
Ejemplo n.º 30
0
	void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }