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