auth.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _AUTH_H
  2. # define _AUTH_H
  3. # include "crypt.h"
  4. #include <bdlib/src/String.h>
  5. #include <bdlib/src/HashTable.h>
  6. #define AUTHED 1
  7. #define AUTHING 2
  8. /* These are what we are expecting back from the user */
  9. #define AUTH_PASS 3
  10. #define AUTH_HASH 4
  11. #define AUTH_BDHASH 5
  12. class Auth {
  13. public:
  14. Auth(const char *, const char *, struct userrec * = NULL);
  15. ~Auth();
  16. int Status(int newstat = -1) { if (newstat >= 0) { status = newstat; } return status; }
  17. void MakeHash();
  18. bool Authed() { return (status == AUTHED); }
  19. bool GetIdx(const char *);
  20. void Done();
  21. void NewNick(const char *nick);
  22. static Auth *Find(const char * host);
  23. static Auth *Find(const char * handle, bool _hand);
  24. static void NullUsers();
  25. static void FillUsers();
  26. static void ExpireAuths();
  27. static void InitTimer();
  28. static void DeleteAll();
  29. static void TellAuthed(int);
  30. struct userrec *user;
  31. time_t authtime; /* what time they authed at */
  32. time_t atime; /* when they last were active */
  33. int idx; /* do they have an associated idx? */
  34. char hash[MD5_HASH_LENGTH + 1]; /* used for dcc authing */
  35. char rand[51];
  36. char nick[NICKLEN];
  37. char host[UHOSTLEN];
  38. char handle[HANDLEN + 1];
  39. static bd::HashTable<bd::String, Auth*> ht_handle;
  40. static bd::HashTable<bd::String, Auth*> ht_host;
  41. private:
  42. int status;
  43. };
  44. void makehash(struct userrec *u, const char *randstring, char *out, size_t out_size);
  45. int check_auth_dcc(Auth *, const char *, const char *);
  46. #endif /* !_AUTH_H */