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.

dns.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_DNS_H
  17. #define RSPAMD_DNS_H
  18. #include "config.h"
  19. #include "mem_pool.h"
  20. #include "events.h"
  21. #include "logger.h"
  22. #include "rdns.h"
  23. #include "upstream.h"
  24. struct rspamd_config;
  25. struct rspamd_dns_resolver {
  26. struct rdns_resolver *r;
  27. struct event_base *ev_base;
  28. struct upstream_list *ups;
  29. struct rspamd_config *cfg;
  30. gdouble request_timeout;
  31. guint max_retransmits;
  32. };
  33. /* Rspamd DNS API */
  34. /**
  35. * Init DNS resolver, params are obtained from a config file or system file /etc/resolv.conf
  36. */
  37. struct rspamd_dns_resolver * dns_resolver_init (rspamd_logger_t *logger,
  38. struct event_base *ev_base, struct rspamd_config *cfg);
  39. struct rspamd_dns_request_ud;
  40. /**
  41. * Make a DNS request
  42. * @param resolver resolver object
  43. * @param session async session to register event
  44. * @param pool memory pool for storage
  45. * @param cb callback to call on resolve completing
  46. * @param ud user data for callback
  47. * @param type request type
  48. * @param ... string or ip address based on a request type
  49. * @return TRUE if request was sent.
  50. */
  51. struct rspamd_dns_request_ud * make_dns_request (struct rspamd_dns_resolver *resolver,
  52. struct rspamd_async_session *session,
  53. rspamd_mempool_t *pool,
  54. dns_callback_type cb,
  55. gpointer ud,
  56. enum rdns_request_type type,
  57. const char *name);
  58. gboolean make_dns_request_task (struct rspamd_task *task,
  59. dns_callback_type cb,
  60. gpointer ud,
  61. enum rdns_request_type type,
  62. const char *name);
  63. gboolean make_dns_request_task_forced (struct rspamd_task *task,
  64. dns_callback_type cb,
  65. gpointer ud,
  66. enum rdns_request_type type,
  67. const char *name);
  68. #endif