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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /* Allow encrypted requests only using network */
  39. gboolean encrypted_only;
  40. /* Limit of tasks */
  41. guint32 max_tasks;
  42. /* Maximum time for task processing */
  43. gdouble task_timeout;
  44. /* Encryption key */
  45. struct rspamd_cryptobox_keypair *key;
  46. /* Keys cache */
  47. struct rspamd_keypair_cache *keys_cache;
  48. /* Language detector */
  49. struct rspamd_lang_detector *lang_det;
  50. };
  51. /*
  52. * Init scanning routines
  53. */
  54. void rspamd_worker_init_scanner (struct rspamd_worker *worker,
  55. struct event_base *ev_base,
  56. struct rspamd_dns_resolver *resolver,
  57. struct rspamd_lang_detector **plang_det);
  58. /*
  59. * Called on forced timeout
  60. */
  61. void rspamd_task_timeout (gint fd, short what, gpointer ud);
  62. /*
  63. * Called on unexpected IO error (e.g. ECONNRESET)
  64. */
  65. void rspamd_worker_guard_handler (gint fd, short what, void *data);
  66. #endif