registry_internals.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_REGISTRY_INTERNALS_H_H
  3. #define NETDATA_REGISTRY_INTERNALS_H_H 1
  4. #include "registry.h"
  5. #define REGISTRY_URL_FLAGS_DEFAULT 0x00
  6. #define REGISTRY_URL_FLAGS_EXPIRED 0x01
  7. #define REGISTRY_DICTIONARY_OPTIONS (DICT_OPTION_VALUE_LINK_DONT_CLONE | DICT_OPTION_NAME_LINK_DONT_CLONE | DICT_OPTION_SINGLE_THREADED)
  8. #define REGISTRY_VERIFY_COOKIES_GUID "11111111-2222-3333-4444-555555555555"
  9. #define is_dummy_person(person_guid) (strcmp(person_guid, REGISTRY_VERIFY_COOKIES_GUID) == 0)
  10. // ----------------------------------------------------------------------------
  11. // COMMON structures
  12. struct registry {
  13. int enabled;
  14. netdata_mutex_t lock;
  15. // entries counters / statistics
  16. unsigned long long persons_count;
  17. unsigned long long machines_count;
  18. unsigned long long usages_count;
  19. unsigned long long persons_urls_count;
  20. unsigned long long machines_urls_count;
  21. unsigned long long log_count;
  22. // configuration
  23. unsigned long long save_registry_every_entries;
  24. char *registry_domain;
  25. char *hostname;
  26. char *registry_to_announce;
  27. char *cloud_base_url;
  28. time_t persons_expiration; // seconds to expire idle persons
  29. int verify_cookies_redirects;
  30. int enable_cookies_samesite_secure;
  31. size_t max_url_length;
  32. size_t max_name_length;
  33. // file/path names
  34. char *pathname;
  35. char *db_filename;
  36. char *log_filename;
  37. char *machine_guid_filename;
  38. // open files
  39. FILE *log_fp;
  40. // the database
  41. DICTIONARY *persons; // dictionary of REGISTRY_PERSON *, with key the REGISTRY_PERSON.guid
  42. DICTIONARY *machines; // dictionary of REGISTRY_MACHINE *, with key the REGISTRY_MACHINE.guid
  43. ARAL *persons_aral;
  44. ARAL *machines_aral;
  45. ARAL *person_urls_aral;
  46. ARAL *machine_urls_aral;
  47. struct aral_statistics aral_stats;
  48. };
  49. #include "registry_machine.h"
  50. #include "registry_person.h"
  51. #include "registry.h"
  52. extern struct registry registry;
  53. // REGISTRY LOW-LEVEL REQUESTS (in registry-internals.c)
  54. REGISTRY_PERSON *registry_request_access(const char *person_guid, char *machine_guid, char *url, char *name, time_t when);
  55. REGISTRY_PERSON *registry_request_delete(const char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
  56. REGISTRY_MACHINE *registry_request_machine(const char *person_guid, char *request_machine, STRING **hostname);
  57. // REGISTRY LOG (in registry_log.c)
  58. void registry_log(char action, REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *u, const char *name);
  59. int registry_log_open(void);
  60. void registry_log_close(void);
  61. void registry_log_recreate(void);
  62. ssize_t registry_log_load(void);
  63. // REGISTRY DB (in registry_db.c)
  64. int registry_db_save(void);
  65. size_t registry_db_load(void);
  66. int registry_db_should_be_saved(void);
  67. #endif //NETDATA_REGISTRY_INTERNALS_H_H