You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

worker_private.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef RSPAMD_WORKER_PRIVATE_H
  17. #define RSPAMD_WORKER_PRIVATE_H
  18. #include "config.h"
  19. #include "libcryptobox/cryptobox.h"
  20. #include "libcryptobox/keypair.h"
  21. #include "libserver/task.h"
  22. #include "libserver/cfg_file.h"
  23. #include "libserver/rspamd_control.h"
  24. static const guint64 rspamd_worker_magic = 0xb48abc69d601dc1dULL;
  25. struct rspamd_lang_detector;
  26. struct rspamd_worker_ctx {
  27. guint64 magic;
  28. /* Events base */
  29. struct event_base *ev_base;
  30. /* DNS resolver */
  31. struct rspamd_dns_resolver *resolver;
  32. /* Config */
  33. struct rspamd_config *cfg;
  34. guint32 timeout;
  35. struct timeval io_tv;
  36. /* Detect whether this worker is mime worker */
  37. gboolean is_mime;
  38. /* HTTP worker */
  39. gboolean is_http;
  40. /* JSON output */
  41. gboolean is_json;
  42. /* Allow learning through worker */
  43. gboolean allow_learn;
  44. /* Limit of tasks */
  45. guint32 max_tasks;
  46. /* Maximum time for task processing */
  47. gdouble task_timeout;
  48. /* Encryption key */
  49. struct rspamd_cryptobox_keypair *key;
  50. /* Keys cache */
  51. struct rspamd_keypair_cache *keys_cache;
  52. /* Language detector */
  53. struct rspamd_lang_detector *lang_det;
  54. };
  55. /*
  56. * Init scanning routines
  57. */
  58. void rspamd_worker_init_scanner (struct rspamd_worker *worker,
  59. struct event_base *ev_base,
  60. struct rspamd_dns_resolver *resolver,
  61. struct rspamd_lang_detector **plang_det);
  62. /*
  63. * Called on forced timeout
  64. */
  65. void rspamd_task_timeout (gint fd, short what, gpointer ud);
  66. /*
  67. * Called on unexpected IO error (e.g. ECONNRESET)
  68. */
  69. void rspamd_worker_guard_handler (gint fd, short what, void *data);
  70. #endif