mirror of
https://github.com/anope/anope.git
synced 2026-07-10 19:03:13 +02:00
Add the initial version of the Atheme database importer.
This commit is contained in:
@@ -1105,6 +1105,22 @@ mail
|
||||
#hash = "md5"
|
||||
}
|
||||
|
||||
/*
|
||||
* db_atheme
|
||||
*
|
||||
* This allows importing databases from Atheme. You should load another database module as
|
||||
* well as this as it can only read Atheme databases not write them.
|
||||
*/
|
||||
#module
|
||||
{
|
||||
name = "db_atheme"
|
||||
|
||||
/*
|
||||
* The database name db_atheme should use.
|
||||
*/
|
||||
database = "atheme.db"
|
||||
}
|
||||
|
||||
/*
|
||||
* [RECOMMENDED] db_flatfile
|
||||
*
|
||||
|
||||
@@ -590,6 +590,9 @@ public:
|
||||
*/
|
||||
sepstream(const Anope::string &source, char separator, bool allowempty = false);
|
||||
|
||||
/** Retrieves the underlying string. */
|
||||
const auto &GetString() const { return tokens; }
|
||||
|
||||
/** Fetch the next token from the stream
|
||||
* @param token The next token from the stream is placed here
|
||||
* @return True if tokens still remain, false if there are none left
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2024 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class HostRequest
|
||||
{
|
||||
protected:
|
||||
HostRequest() = default;
|
||||
|
||||
public:
|
||||
Anope::string nick;
|
||||
Anope::string ident;
|
||||
Anope::string host;
|
||||
time_t time = 0;
|
||||
|
||||
virtual ~HostRequest() = default;
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2024 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class OperInfo
|
||||
{
|
||||
protected:
|
||||
OperInfo() = default;
|
||||
|
||||
OperInfo(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c)
|
||||
: target(t)
|
||||
, info(i)
|
||||
, adder(a)
|
||||
, created(c)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
Anope::string target;
|
||||
Anope::string info;
|
||||
Anope::string adder;
|
||||
time_t created = 0;
|
||||
|
||||
virtual ~OperInfo() = default;
|
||||
};
|
||||
|
||||
class OperInfoList
|
||||
: public Serialize::Checker<std::vector<OperInfo *>>
|
||||
{
|
||||
public:
|
||||
OperInfoList()
|
||||
: Serialize::Checker<std::vector<OperInfo *>>("OperInfo")
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~OperInfoList()
|
||||
{
|
||||
for (auto *info : *(*this))
|
||||
delete info;
|
||||
}
|
||||
|
||||
virtual OperInfo *Create() = 0;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -278,8 +278,6 @@ public:
|
||||
ESHA256(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR),
|
||||
sha256provider(this)
|
||||
{
|
||||
|
||||
|
||||
use_iv = false;
|
||||
}
|
||||
|
||||
@@ -324,10 +322,10 @@ public:
|
||||
this->OnEncrypt(req->GetPassword(), buf);
|
||||
if (nc->pass.equals_cs(buf))
|
||||
{
|
||||
/* if we are NOT the first module in the list,
|
||||
/* if we are NOT the first module in the list or we are using a default IV
|
||||
* we want to re-encrypt the pass with the new encryption
|
||||
*/
|
||||
if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
|
||||
if (ModuleManager::FindFirstOf(ENCRYPTION) != this || !memcmp(iv, sha256_h0, 8))
|
||||
Anope::Encrypt(req->GetPassword(), nc->pass);
|
||||
req->Success(this);
|
||||
}
|
||||
|
||||
@@ -15,20 +15,20 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "modules/hs_request.h"
|
||||
|
||||
static ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ");
|
||||
|
||||
static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost);
|
||||
|
||||
struct HostRequest final
|
||||
: Serializable
|
||||
struct HostRequestImpl final
|
||||
: HostRequest
|
||||
, Serializable
|
||||
{
|
||||
Anope::string nick;
|
||||
Anope::string ident;
|
||||
Anope::string host;
|
||||
time_t time;
|
||||
|
||||
HostRequest(Extensible *) : Serializable("HostRequest") { }
|
||||
HostRequestImpl(Extensible *)
|
||||
: Serializable("HostRequest")
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
{
|
||||
@@ -47,11 +47,11 @@ struct HostRequest final
|
||||
if (na == NULL)
|
||||
return NULL;
|
||||
|
||||
HostRequest *req;
|
||||
HostRequestImpl *req;
|
||||
if (obj)
|
||||
req = anope_dynamic_static_cast<HostRequest *>(obj);
|
||||
req = anope_dynamic_static_cast<HostRequestImpl *>(obj);
|
||||
else
|
||||
req = na->Extend<HostRequest>("hostrequest");
|
||||
req = na->Extend<HostRequestImpl>("hostrequest");
|
||||
if (req)
|
||||
{
|
||||
req->nick = na->nick;
|
||||
@@ -162,12 +162,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
HostRequest req(na);
|
||||
HostRequestImpl req(na);
|
||||
req.nick = source.GetNick();
|
||||
req.ident = user;
|
||||
req.host = host;
|
||||
req.time = Anope::CurTime;
|
||||
na->Extend<HostRequest>("hostrequest", req);
|
||||
na->Extend<HostRequestImpl>("hostrequest", req);
|
||||
|
||||
source.Reply(_("Your vHost has been requested."));
|
||||
req_send_memos(owner, source, user, host);
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
const Anope::string &nick = params[0];
|
||||
|
||||
NickAlias *na = NickAlias::Find(nick);
|
||||
HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL;
|
||||
HostRequestImpl *req = na ? na->GetExt<HostRequestImpl>("hostrequest") : NULL;
|
||||
if (req)
|
||||
{
|
||||
na->SetVhost(req->ident, req->host, source.GetNick(), req->time);
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
|
||||
source.Reply(_("vHost for %s has been activated."), na->nick.c_str());
|
||||
Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host;
|
||||
na->Shrink<HostRequest>("hostrequest");
|
||||
na->Shrink<HostRequestImpl>("hostrequest");
|
||||
}
|
||||
else
|
||||
source.Reply(_("No request for nick %s found."), nick.c_str());
|
||||
@@ -257,10 +257,10 @@ public:
|
||||
const Anope::string &reason = params.size() > 1 ? params[1] : "";
|
||||
|
||||
NickAlias *na = NickAlias::Find(nick);
|
||||
HostRequest *req = na ? na->GetExt<HostRequest>("hostrequest") : NULL;
|
||||
HostRequestImpl *req = na ? na->GetExt<HostRequestImpl>("hostrequest") : NULL;
|
||||
if (req)
|
||||
{
|
||||
na->Shrink<HostRequest>("hostrequest");
|
||||
na->Shrink<HostRequestImpl>("hostrequest");
|
||||
|
||||
if (Config->GetModule(this->owner)->Get<bool>("memouser") && memoserv)
|
||||
{
|
||||
@@ -311,7 +311,7 @@ public:
|
||||
|
||||
for (const auto &[nick, na] : *NickAliasList)
|
||||
{
|
||||
HostRequest *hr = na->GetExt<HostRequest>("hostrequest");
|
||||
HostRequestImpl *hr = na->GetExt<HostRequestImpl>("hostrequest");
|
||||
if (!hr)
|
||||
continue;
|
||||
|
||||
@@ -358,13 +358,13 @@ class HSRequest final
|
||||
CommandHSActivate commandhsactive;
|
||||
CommandHSReject commandhsreject;
|
||||
CommandHSWaiting commandhswaiting;
|
||||
ExtensibleItem<HostRequest> hostrequest;
|
||||
ExtensibleItem<HostRequestImpl> hostrequest;
|
||||
Serialize::Type request_type;
|
||||
|
||||
public:
|
||||
HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandhsrequest(this), commandhsactive(this),
|
||||
commandhsreject(this), commandhswaiting(this), hostrequest(this, "hostrequest"), request_type("HostRequest", HostRequest::Unserialize)
|
||||
commandhsreject(this), commandhswaiting(this), hostrequest(this, "hostrequest"), request_type("HostRequest", HostRequestImpl::Unserialize)
|
||||
{
|
||||
if (!IRCD || !IRCD->CanSetVHost)
|
||||
throw ModuleException("Your IRCd does not support vhosts");
|
||||
|
||||
@@ -7,20 +7,24 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "modules/info.h"
|
||||
|
||||
struct OperInfo final
|
||||
: Serializable
|
||||
struct OperInfoImpl final
|
||||
: OperInfo
|
||||
, Serializable
|
||||
{
|
||||
Anope::string target;
|
||||
Anope::string info;
|
||||
Anope::string adder;
|
||||
time_t created = 0;
|
||||
OperInfoImpl()
|
||||
: Serializable("OperInfo")
|
||||
{
|
||||
}
|
||||
|
||||
OperInfo() : Serializable("OperInfo") { }
|
||||
OperInfo(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c) :
|
||||
Serializable("OperInfo"), target(t), info(i), adder(a), created(c) { }
|
||||
OperInfoImpl(const Anope::string &t, const Anope::string &i, const Anope::string &a, time_t c)
|
||||
: OperInfo(t, i, a, c)
|
||||
, Serializable("OperInfo")
|
||||
{
|
||||
}
|
||||
|
||||
~OperInfo() override;
|
||||
~OperInfoImpl() override;
|
||||
|
||||
void Serialize(Serialize::Data &data) const override
|
||||
{
|
||||
@@ -34,14 +38,13 @@ struct OperInfo final
|
||||
};
|
||||
|
||||
struct OperInfos final
|
||||
: Serialize::Checker<std::vector<OperInfo *> >
|
||||
: OperInfoList
|
||||
{
|
||||
OperInfos(Extensible *) : Serialize::Checker<std::vector<OperInfo *> >("OperInfo") { }
|
||||
OperInfos(Extensible *) { }
|
||||
|
||||
~OperInfos()
|
||||
OperInfo *Create() override
|
||||
{
|
||||
for (unsigned i = (*this)->size(); i > 0; --i)
|
||||
delete (*this)->at(i - 1);
|
||||
return new OperInfoImpl();
|
||||
}
|
||||
|
||||
static Extensible *Find(const Anope::string &target)
|
||||
@@ -53,7 +56,7 @@ struct OperInfos final
|
||||
}
|
||||
};
|
||||
|
||||
OperInfo::~OperInfo()
|
||||
OperInfoImpl::~OperInfoImpl()
|
||||
{
|
||||
Extensible *e = OperInfos::Find(target);
|
||||
if (e)
|
||||
@@ -68,7 +71,7 @@ OperInfo::~OperInfo()
|
||||
}
|
||||
}
|
||||
|
||||
Serializable *OperInfo::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
Serializable *OperInfoImpl::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
Anope::string starget;
|
||||
data["target"] >> starget;
|
||||
@@ -78,12 +81,12 @@ Serializable *OperInfo::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
return NULL;
|
||||
|
||||
OperInfos *oi = e->Require<OperInfos>("operinfo");
|
||||
OperInfo *o;
|
||||
OperInfoImpl *o;
|
||||
if (obj)
|
||||
o = anope_dynamic_static_cast<OperInfo *>(obj);
|
||||
o = anope_dynamic_static_cast<OperInfoImpl *>(obj);
|
||||
else
|
||||
{
|
||||
o = new OperInfo();
|
||||
o = new OperInfoImpl();
|
||||
o->target = starget;
|
||||
}
|
||||
data["info"] >> o->info;
|
||||
@@ -160,7 +163,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
(*oi)->push_back(new OperInfo(target, info, source.GetNick(), Anope::CurTime));
|
||||
(*oi)->push_back(new OperInfoImpl(target, info, source.GetNick(), Anope::CurTime));
|
||||
|
||||
source.Reply(_("Added info to \002%s\002."), target.c_str());
|
||||
Log(LOG_ADMIN, source, this) << "to add information to " << target;
|
||||
@@ -272,7 +275,7 @@ class OSInfo final
|
||||
|
||||
public:
|
||||
OSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
|
||||
commandosinfo(this), oinfo(this, "operinfo"), oinfo_type("OperInfo", OperInfo::Unserialize)
|
||||
commandosinfo(this), oinfo(this, "operinfo"), oinfo_type("OperInfo", OperInfoImpl::Unserialize)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user