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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 ev_loop *event_loop;
  30. /* DNS resolver */
  31. struct rspamd_dns_resolver *resolver;
  32. /* Config */
  33. struct rspamd_config *cfg;
  34. ev_tstamp timeout;
  35. /* Detect whether this worker is mime worker */
  36. gboolean is_mime;
  37. /* Allow encrypted requests only using network */
  38. gboolean encrypted_only;
  39. /* Limit of tasks */
  40. guint32 max_tasks;
  41. /* Maximum time for task processing */
  42. ev_tstamp task_timeout;
  43. /* Encryption key */
  44. struct rspamd_cryptobox_keypair *key;
  45. /* Keys cache */
  46. struct rspamd_http_context *http_ctx;
  47. /* Language detector */
  48. struct rspamd_lang_detector *lang_det;
  49. };
  50. /*
  51. * Init scanning routines
  52. */
  53. void rspamd_worker_init_scanner (struct rspamd_worker *worker,
  54. struct ev_loop *ev_base,
  55. struct rspamd_dns_resolver *resolver,
  56. struct rspamd_lang_detector **plang_det);
  57. /*
  58. * Called on forced timeout
  59. */
  60. void rspamd_task_timeout (EV_P_ ev_timer *w, int revents);
  61. /*
  62. * Called on unexpected IO error (e.g. ECONNRESET)
  63. */
  64. void rspamd_worker_guard_handler (EV_P_ ev_io *w, int revents);
  65. #endif