auth.h 1.5 KB

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