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

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