dns.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file dns.h
  8. * \brief Header file for dns.c.
  9. **/
  10. #ifndef TOR_DNS_H
  11. #define TOR_DNS_H
  12. /** Lowest value for DNS ttl that a server will give. */
  13. #define MIN_DNS_TTL_AT_EXIT (5*60)
  14. /** Highest value for DNS ttl that a server will give. */
  15. #define MAX_DNS_TTL_AT_EXIT (60*60)
  16. /** How long do we keep DNS cache entries before purging them (regardless of
  17. * their TTL)? */
  18. #define MAX_DNS_ENTRY_AGE (3*60*60)
  19. /** How long do we cache/tell clients to cache DNS records when no TTL is
  20. * known? */
  21. #define DEFAULT_DNS_TTL (30*60)
  22. int dns_init(void);
  23. int has_dns_init_failed(void);
  24. void dns_free_all(void);
  25. uint32_t dns_clip_ttl(uint32_t ttl);
  26. int dns_reset(void);
  27. void connection_dns_remove(edge_connection_t *conn);
  28. void assert_connection_edge_not_dns_pending(edge_connection_t *conn);
  29. void assert_all_pending_dns_resolves_ok(void);
  30. MOCK_DECL(void,dns_cancel_pending_resolve,(const char *question));
  31. int dns_resolve(edge_connection_t *exitconn);
  32. void dns_launch_correctness_checks(void);
  33. int dns_seems_to_be_broken(void);
  34. int dns_seems_to_be_broken_for_ipv6(void);
  35. void dns_reset_correctness_checks(void);
  36. size_t dns_cache_total_allocation(void);
  37. void dump_dns_mem_usage(int severity);
  38. size_t dns_cache_handle_oom(time_t now, size_t min_remove_bytes);
  39. #ifdef DNS_PRIVATE
  40. #include "feature/relay/dns_structs.h"
  41. MOCK_DECL(STATIC int,dns_resolve_impl,(edge_connection_t *exitconn,
  42. int is_resolve,or_circuit_t *oncirc, char **hostname_out,
  43. int *made_connection_pending_out, cached_resolve_t **resolve_out));
  44. MOCK_DECL(STATIC void,send_resolved_cell,(edge_connection_t *conn,
  45. uint8_t answer_type,const cached_resolve_t *resolved));
  46. MOCK_DECL(STATIC void,send_resolved_hostname_cell,(edge_connection_t *conn,
  47. const char *hostname));
  48. cached_resolve_t *dns_get_cache_entry(cached_resolve_t *query);
  49. void dns_insert_cache_entry(cached_resolve_t *new_entry);
  50. MOCK_DECL(STATIC int,
  51. set_exitconn_info_from_resolve,(edge_connection_t *exitconn,
  52. const cached_resolve_t *resolve,
  53. char **hostname_out));
  54. MOCK_DECL(STATIC int,
  55. launch_resolve,(cached_resolve_t *resolve));
  56. #endif /* defined(DNS_PRIVATE) */
  57. #endif /* !defined(TOR_DNS_H) */