ddnet/src/engine/server/authmanager.h

48 lines
1.2 KiB
C
Raw Normal View History

#ifndef ENGINE_SERVER_AUTHMANAGER_H
#define ENGINE_SERVER_AUTHMANAGER_H
2017-03-02 15:16:29 +00:00
2022-05-23 21:04:19 +00:00
#include <vector>
#include <base/hash.h>
2017-03-02 15:16:29 +00:00
#define SALT_BYTES 8
class CAuthManager
{
private:
struct CKey
{
char m_aIdent[64];
MD5_DIGEST m_Pw;
2017-03-02 15:16:29 +00:00
unsigned char m_aSalt[SALT_BYTES];
int m_Level;
};
2022-05-23 21:04:19 +00:00
std::vector<CKey> m_vKeys;
2017-03-02 15:16:29 +00:00
int m_aDefault[3];
2017-03-04 20:06:22 +00:00
bool m_Generated;
2017-03-02 15:16:29 +00:00
public:
typedef void (*FListCallback)(const char *pIdent, int Level, void *pUser);
CAuthManager();
void Init();
int AddKeyHash(const char *pIdent, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel);
2017-03-02 15:16:29 +00:00
int AddKey(const char *pIdent, const char *pPw, int AuthLevel);
int RemoveKey(int Slot); // Returns the old key slot that is now in the named one.
int FindKey(const char *pIdent) const;
bool CheckKey(int Slot, const char *pPw) const;
int DefaultKey(int AuthLevel) const;
int KeyLevel(int Slot) const;
const char *KeyIdent(int Slot) const;
void UpdateKeyHash(int Slot, MD5_DIGEST Hash, const unsigned char *pSalt, int AuthLevel);
2017-03-02 15:16:29 +00:00
void UpdateKey(int Slot, const char *pPw, int AuthLevel);
void ListKeys(FListCallback pfnListCallbac, void *pUser);
void AddDefaultKey(int Level, const char *pPw);
bool IsGenerated() const;
int NumNonDefaultKeys() const;
2017-03-02 15:16:29 +00:00
};
#endif //ENGINE_SERVER_AUTHMANAGER_H