Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. /* 1 worker by default */
  33. #define DEFAULT_WORKERS_NUM 1
  34. #define yyerror(fmt, ...) \
  35. fprintf (stderr, "Config file parse error!\non line: %d\n", yylineno); \
  36. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  37. fprintf (stderr, fmt, ##__VA_ARGS__); \
  38. fprintf (stderr, "\n")
  39. #define yywarn(fmt, ...) \
  40. fprintf (stderr, "Config file parse warning!\non line %d\n", yylineno); \
  41. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  42. fprintf (stderr, fmt, ##__VA_ARGS__); \
  43. fprintf (stderr, "\n")
  44. struct expression;
  45. enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
  46. enum rspamd_regexp_type {
  47. REGEXP_NONE = 0,
  48. REGEXP_HEADER,
  49. REGEXP_MIME,
  50. REGEXP_MESSAGE,
  51. REGEXP_URL,
  52. };
  53. enum rspamd_log_type {
  54. RSPAMD_LOG_CONSOLE,
  55. RSPAMD_LOG_SYSLOG,
  56. RSPAMD_LOG_FILE,
  57. };
  58. struct rspamd_regexp {
  59. enum rspamd_regexp_type type;
  60. char *regexp_text;
  61. GRegex *regexp;
  62. char *header;
  63. };
  64. struct memcached_server {
  65. struct upstream up;
  66. struct in_addr addr;
  67. uint16_t port;
  68. short alive;
  69. short int num;
  70. };
  71. struct perl_module {
  72. char *path;
  73. LIST_ENTRY (perl_module) next;
  74. };
  75. struct module_opt {
  76. char *param;
  77. char *value;
  78. LIST_ENTRY (module_opt) next;
  79. };
  80. struct config_file {
  81. memory_pool_t *cfg_pool;
  82. char *cfg_name;
  83. char *pid_file;
  84. char *temp_dir;
  85. char *bind_host;
  86. struct in_addr bind_addr;
  87. uint16_t bind_port;
  88. uint16_t bind_family;
  89. char *control_host;
  90. struct in_addr control_addr;
  91. uint16_t control_port;
  92. uint16_t control_family;
  93. int controller_enabled;
  94. char *control_password;
  95. int no_fork;
  96. unsigned int workers_number;
  97. enum rspamd_log_type log_type;
  98. int log_facility;
  99. int log_level;
  100. char *log_file;
  101. int log_fd;
  102. struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];
  103. size_t memcached_servers_num;
  104. memc_proto_t memcached_protocol;
  105. unsigned int memcached_error_time;
  106. unsigned int memcached_dead_time;
  107. unsigned int memcached_maxerrors;
  108. unsigned int memcached_connect_timeout;
  109. LIST_HEAD (modulesq, perl_module) perl_modules;
  110. LIST_HEAD (headersq, filter) header_filters;
  111. LIST_HEAD (mimesq, filter) mime_filters;
  112. LIST_HEAD (messagesq, filter) message_filters;
  113. LIST_HEAD (urlsq, filter) url_filters;
  114. char *header_filters_str;
  115. char *mime_filters_str;
  116. char *message_filters_str;
  117. char *url_filters_str;
  118. GHashTable* modules_opts;
  119. GHashTable* variables;
  120. GHashTable* metrics;
  121. GHashTable* factors;
  122. GHashTable* c_modules;
  123. GHashTable* composite_symbols;
  124. };
  125. int add_memcached_server (struct config_file *cf, char *str);
  126. int parse_bind_line (struct config_file *cf, char *str, char is_control);
  127. void init_defaults (struct config_file *cfg);
  128. void free_config (struct config_file *cfg);
  129. char* get_module_opt (struct config_file *cfg, char *module_name, char *opt_name);
  130. size_t parse_limit (const char *limit);
  131. unsigned int parse_seconds (const char *t);
  132. char parse_flag (const char *str);
  133. char* substitute_variable (struct config_file *cfg, char *str, u_char recursive);
  134. void post_load_config (struct config_file *cfg);
  135. struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line);
  136. struct expression* parse_expression (memory_pool_t *pool, char *line);
  137. int yylex (void);
  138. int yyparse (void);
  139. void yyrestart (FILE *);
  140. #endif /* ifdef CFG_FILE_H */
  141. /*
  142. * vi:ts=4
  143. */