From 8180dd414ecd43758290c20315e70af72f0833bf Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 10 Sep 2020 15:15:34 +0100 Subject: Implement support for immutable account identifiers. --- include/account.h | 10 +++++++++- include/anope.h | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/account.h b/include/account.h index 8cb2e7a8e..a65c390ea 100644 --- a/include/account.h +++ b/include/account.h @@ -20,9 +20,11 @@ typedef Anope::hash_map nickalias_map; typedef Anope::hash_map nickcore_map; +typedef TR1NS::unordered_map nickcoreid_map; extern CoreExport Serialize::Checker NickAliasList; extern CoreExport Serialize::Checker NickCoreList; +extern CoreExport nickcoreid_map NickCoreIdList; /* A registered nickname. * It matters that Base is here before Extensible (it is inherited by Serializable) @@ -107,6 +109,8 @@ class CoreExport NickCore : public Serializable, public Extensible { /* Channels which reference this core in some way (this is on their access list, akick list, is founder, successor, etc) */ Serialize::Checker > chanaccess; + /* Unique identifier for the account. */ + uint64_t id; public: /* Name of the account. Find(display)->nc == this. */ Anope::string display; @@ -140,8 +144,9 @@ class CoreExport NickCore : public Serializable, public Extensible /** Constructor * @param display The display nick + * @param id The account id */ - NickCore(const Anope::string &nickdisplay); + NickCore(const Anope::string &nickdisplay, uint64_t nickid = 0); ~NickCore(); void Serialize(Serialize::Data &data) const anope_override; @@ -178,6 +183,9 @@ class CoreExport NickCore : public Serializable, public Extensible */ unsigned GetAccessCount() const; + /** Retrieves the account id for this user */ + uint64_t GetId(); + /** Find an entry in the nick's access list * * @param entry The nick!ident@host entry to search for diff --git a/include/anope.h b/include/anope.h index e53f5c3a6..d4a351a93 100644 --- a/include/anope.h +++ b/include/anope.h @@ -470,6 +470,13 @@ namespace Anope */ extern CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest); + /** Hashes a buffer with SipHash-2-4 + * @param src The start of the buffer to hash + * @param src_sz The total number of bytes in the buffer + * @param key A 16 byte key to hash the buffer with. + */ + extern CoreExport uint64_t SipHash24(const void *src, unsigned long src_sz, const char key[16]); + /** Returns a sequence of data formatted as the format argument specifies. ** After the format parameter, the function expects at least as many ** additional arguments as specified in format. -- cgit