4 * this header file describes the public interface
5 * to the netdata registry
7 * only these high level functions are exposed
11 // ----------------------------------------------------------------------------
14 // 1. the default tracking cookie expires in 1 year, but the persons are not
15 // removed from the db - this means the database only grows - ideally the
16 // database should be cleaned in registry_db_save() for both on-disk and
20 // i. Find all the PERSONs that have expired cookie
21 // ii. For each of their PERSON_URLs:
22 // - decrement the linked MACHINE links
23 // - if the linked MACHINE has no other links, remove the linked MACHINE too
24 // - remove the PERSON_URL
26 // 2. add protection to prevent abusing the registry by flooding it with
27 // requests to fill the memory and crash it.
29 // Possible protections:
30 // - limit the number of URLs per person
31 // - limit the number of URLs per machine
32 // - limit the number of persons
33 // - limit the number of machines
34 // - [DONE] limit the size of URLs
35 // - [DONE] limit the size of PERSON_URL names
36 // - limit the number of requests that add data to the registry,
37 // per client IP per hour
39 // 3. lower memory requirements
41 // - embed avl structures directly into registry objects, instead of DICTIONARY
42 // [DONE for PERSON_URLs, PENDING for MACHINE_URLs]
43 // - store GUIDs in memory as UUID instead of char *
44 // - do not track persons using the demo machines only
45 // (i.e. start tracking them only when they access a non-demo machine)
46 // - [DONE] do not track custom dashboards by default
49 #ifndef NETDATA_REGISTRY_H
50 #define NETDATA_REGISTRY_H 1
52 #define NETDATA_REGISTRY_COOKIE_NAME "netdata_registry_id"
54 // initialize the registry
55 // should only happen when netdata starts
56 extern int registry_init(void);
58 // free all data held by the registry
59 // should only happen when netdata exits
60 extern void registry_free(void);
62 // HTTP requests handled by the registry
63 extern int registry_request_access_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *name, time_t when);
64 extern int registry_request_delete_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
65 extern int registry_request_search_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when);
66 extern int registry_request_switch_json(RRDHOST *host, struct web_client *w, char *person_guid, char *machine_guid, char *url, char *new_person_guid, time_t when);
67 extern int registry_request_hello_json(RRDHOST *host, struct web_client *w);
69 // update the registry monitoring charts
70 extern void registry_statistics(void);
72 extern char *registry_get_this_machine_guid(void);
73 extern int regenerate_guid(const char *guid, char *result);
75 #endif /* NETDATA_REGISTRY_H */