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 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. static const uint64_t rspamd_worker_magic = 0xb48abc69d601dc1dULL;
  28. struct rspamd_lang_detector;
  29. struct rspamd_worker_ctx {
  30. uint64_t magic;
  31. /* Events base */
  32. struct ev_loop *event_loop;
  33. /* DNS resolver */
  34. struct rspamd_dns_resolver *resolver;
  35. /* Config */
  36. struct rspamd_config *cfg;
  37. ev_tstamp timeout;
  38. /* Detect whether this worker is mime worker */
  39. gboolean is_mime;
  40. /* Allow encrypted requests only using network */
  41. gboolean encrypted_only;
  42. /* Limit of tasks */
  43. uint32_t max_tasks;
  44. /* Maximum time for task processing */
  45. ev_tstamp task_timeout;
  46. /* Encryption key */
  47. struct rspamd_cryptobox_keypair *key;
  48. /* Keys cache */
  49. struct rspamd_http_context *http_ctx;
  50. /* Language detector */
  51. struct rspamd_lang_detector *lang_det;
  52. };
  53. /*
  54. * Init scanning routines
  55. */
  56. void rspamd_worker_init_scanner(struct rspamd_worker *worker,
  57. struct ev_loop *ev_base,
  58. struct rspamd_dns_resolver *resolver,
  59. struct rspamd_lang_detector **plang_det);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif