Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

cfg_file.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * $Id$
  3. */
  4. #ifndef CFG_FILE_H
  5. #define CFG_FILE_H
  6. #include "config.h"
  7. #include <sys/types.h>
  8. #ifndef HAVE_OWN_QUEUE_H
  9. #include <sys/queue.h>
  10. #else
  11. #include "queue.h"
  12. #endif
  13. #include <netinet/in.h>
  14. #include <sys/un.h>
  15. #include <event.h>
  16. #include <glib.h>
  17. #include "mem_pool.h"
  18. #include "upstream.h"
  19. #include "memcached.h"
  20. #include "filter.h"
  21. #define DEFAULT_BIND_PORT 768
  22. #define DEFAULT_CONTROL_PORT 7608
  23. #define MAX_MEMCACHED_SERVERS 48
  24. #define DEFAULT_MEMCACHED_PORT 11211
  25. /* Memcached timeouts */
  26. #define DEFAULT_MEMCACHED_CONNECT_TIMEOUT 1000
  27. /* Upstream timeouts */
  28. #define DEFAULT_UPSTREAM_ERROR_TIME 10
  29. #define DEFAULT_UPSTREAM_ERROR_TIME 10
  30. #define DEFAULT_UPSTREAM_DEAD_TIME 300
  31. #define DEFAULT_UPSTREAM_MAXERRORS 10
  32. /* Statfile pool size, 50Mb */
  33. #define DEFAULT_STATFILE_SIZE 52428800L
  34. /* 1 worker by default */
  35. #define DEFAULT_WORKERS_NUM 1
  36. #define yyerror(fmt, ...) \
  37. fprintf (stderr, "Config file parse error!\non line: %d\n", yylineno); \
  38. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  39. fprintf (stderr, fmt, ##__VA_ARGS__); \
  40. fprintf (stderr, "\n")
  41. #define yywarn(fmt, ...) \
  42. fprintf (stderr, "Config file parse warning!\non line %d\n", yylineno); \
  43. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  44. fprintf (stderr, fmt, ##__VA_ARGS__); \
  45. fprintf (stderr, "\n")
  46. struct expression;
  47. enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
  48. enum rspamd_regexp_type {
  49. REGEXP_NONE = 0,
  50. REGEXP_HEADER,
  51. REGEXP_MIME,
  52. REGEXP_MESSAGE,
  53. REGEXP_URL,
  54. };
  55. enum rspamd_log_type {
  56. RSPAMD_LOG_CONSOLE,
  57. RSPAMD_LOG_SYSLOG,
  58. RSPAMD_LOG_FILE,
  59. };
  60. struct rspamd_regexp {
  61. enum rspamd_regexp_type type;
  62. char *regexp_text;
  63. GRegex *regexp;
  64. char *header;
  65. };
  66. struct memcached_server {
  67. struct upstream up;
  68. struct in_addr addr;
  69. uint16_t port;
  70. short alive;
  71. short int num;
  72. };
  73. struct perl_module {
  74. char *path;
  75. LIST_ENTRY (perl_module) next;
  76. };
  77. struct module_opt {
  78. char *param;
  79. char *value;
  80. LIST_ENTRY (module_opt) next;
  81. };
  82. struct statfile {
  83. char *alias;
  84. char *pattern;
  85. double weight;
  86. size_t size;
  87. };
  88. struct config_file {
  89. memory_pool_t *cfg_pool;
  90. char *cfg_name;
  91. char *pid_file;
  92. char *temp_dir;
  93. char *bind_host;
  94. struct in_addr bind_addr;
  95. uint16_t bind_port;
  96. uint16_t bind_family;
  97. char *control_host;
  98. struct in_addr control_addr;
  99. uint16_t control_port;
  100. uint16_t control_family;
  101. int controller_enabled;
  102. char *control_password;
  103. int no_fork;
  104. unsigned int workers_number;
  105. enum rspamd_log_type log_type;
  106. int log_facility;
  107. int log_level;
  108. char *log_file;
  109. int log_fd;
  110. size_t max_statfile_size;
  111. struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];
  112. size_t memcached_servers_num;
  113. memc_proto_t memcached_protocol;
  114. unsigned int memcached_error_time;
  115. unsigned int memcached_dead_time;
  116. unsigned int memcached_maxerrors;
  117. unsigned int memcached_connect_timeout;
  118. LIST_HEAD (modulesq, perl_module) perl_modules;
  119. LIST_HEAD (headersq, filter) header_filters;
  120. LIST_HEAD (mimesq, filter) mime_filters;
  121. LIST_HEAD (messagesq, filter) message_filters;
  122. LIST_HEAD (urlsq, filter) url_filters;
  123. char *header_filters_str;
  124. char *mime_filters_str;
  125. char *message_filters_str;
  126. char *url_filters_str;
  127. GHashTable* modules_opts;
  128. GHashTable* variables;
  129. GHashTable* metrics;
  130. GHashTable* factors;
  131. GHashTable* c_modules;
  132. GHashTable* composite_symbols;
  133. GHashTable* statfiles;
  134. };
  135. int add_memcached_server (struct config_file *cf, char *str);
  136. int parse_bind_line (struct config_file *cf, char *str, char is_control);
  137. void init_defaults (struct config_file *cfg);
  138. void free_config (struct config_file *cfg);
  139. char* get_module_opt (struct config_file *cfg, char *module_name, char *opt_name);
  140. size_t parse_limit (const char *limit);
  141. unsigned int parse_seconds (const char *t);
  142. char parse_flag (const char *str);
  143. char* substitute_variable (struct config_file *cfg, char *str, u_char recursive);
  144. void post_load_config (struct config_file *cfg);
  145. struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line);
  146. struct expression* parse_expression (memory_pool_t *pool, char *line);
  147. int yylex (void);
  148. int yyparse (void);
  149. void yyrestart (FILE *);
  150. #endif /* ifdef CFG_FILE_H */
  151. /*
  152. * vi:ts=4
  153. */