diff options
author | Sadie Powell <sadie@witchery.services> | 2020-09-10 15:15:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 15:15:34 +0100 |
commit | 8180dd414ecd43758290c20315e70af72f0833bf (patch) | |
tree | 195ea018ed2d477a114b422caee94053419e77ef /include | |
parent | ff28985384cb6e60fc7479f93778c4363c322ea7 (diff) |
Implement support for immutable account identifiers.
Diffstat (limited to 'include')
-rw-r--r-- | include/account.h | 10 | ||||
-rw-r--r-- | include/anope.h | 7 |
2 files changed, 16 insertions, 1 deletions
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 *> nickalias_map; typedef Anope::hash_map<NickCore *> nickcore_map; +typedef TR1NS::unordered_map<uint64_t, NickCore *> nickcoreid_map; extern CoreExport Serialize::Checker<nickalias_map> NickAliasList; extern CoreExport Serialize::Checker<nickcore_map> 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<std::map<ChannelInfo *, int> > 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. |