aclk_common.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef ACLK_COMMON_H
  2. #define ACLK_COMMON_H
  3. #include "aclk_rrdhost_state.h"
  4. #include "../daemon/common.h"
  5. extern netdata_mutex_t aclk_shared_state_mutex;
  6. #define ACLK_SHARED_STATE_LOCK netdata_mutex_lock(&aclk_shared_state_mutex)
  7. #define ACLK_SHARED_STATE_UNLOCK netdata_mutex_unlock(&aclk_shared_state_mutex)
  8. // minimum and maximum supported version of ACLK
  9. // in this version of agent
  10. #define ACLK_VERSION_MIN 2
  11. #define ACLK_VERSION_MAX 3
  12. // Version negotiation messages have they own versioning
  13. // this is also used for LWT message as we set that up
  14. // before version negotiation
  15. #define ACLK_VERSION_NEG_VERSION 1
  16. // Maximum time to wait for version negotiation before aborting
  17. // and defaulting to oldest supported version
  18. #define VERSION_NEG_TIMEOUT 3
  19. #if ACLK_VERSION_MIN > ACLK_VERSION_MAX
  20. #error "ACLK_VERSION_MAX must be >= than ACLK_VERSION_MIN"
  21. #endif
  22. // Define ACLK Feature Version Boundaries Here
  23. #define ACLK_V_COMPRESSION 2
  24. #define ACLK_V_CHILDRENSTATE 3
  25. #define ACLK_IS_HOST_INITIALIZING(host) (host->aclk_state.state == ACLK_HOST_INITIALIZING)
  26. #define ACLK_IS_HOST_POPCORNING(host) (ACLK_IS_HOST_INITIALIZING(host) && host->aclk_state.t_last_popcorn_update)
  27. extern struct aclk_shared_state {
  28. // optimization to avoid looping trough hosts
  29. // every time Query Thread wakes up
  30. RRDHOST *next_popcorn_host;
  31. // read only while ACLK connected
  32. // protect by lock otherwise
  33. int version_neg;
  34. usec_t version_neg_wait_till;
  35. } aclk_shared_state;
  36. typedef enum aclk_proxy_type {
  37. PROXY_TYPE_UNKNOWN = 0,
  38. PROXY_TYPE_SOCKS5,
  39. PROXY_TYPE_HTTP,
  40. PROXY_DISABLED,
  41. PROXY_NOT_SET,
  42. } ACLK_PROXY_TYPE;
  43. extern int aclk_kill_link; // Tells the agent to tear down the link
  44. extern int aclk_disable_runtime;
  45. const char *aclk_proxy_type_to_s(ACLK_PROXY_TYPE *type);
  46. #define ACLK_PROXY_PROTO_ADDR_SEPARATOR "://"
  47. #define ACLK_PROXY_ENV "env"
  48. #define ACLK_PROXY_CONFIG_VAR "proxy"
  49. ACLK_PROXY_TYPE aclk_verify_proxy(const char *string);
  50. const char *aclk_lws_wss_get_proxy_setting(ACLK_PROXY_TYPE *type);
  51. void safe_log_proxy_censor(char *proxy);
  52. int aclk_decode_base_url(char *url, char **aclk_hostname, int *aclk_port);
  53. const char *aclk_get_proxy(ACLK_PROXY_TYPE *type);
  54. #endif //ACLK_COMMON_H