dns.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-2017, 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. void dump_dns_mem_usage(int severity);
  37. #ifdef DNS_PRIVATE
  38. #include "dns_structs.h"
  39. MOCK_DECL(STATIC int,dns_resolve_impl,(edge_connection_t *exitconn,
  40. int is_resolve,or_circuit_t *oncirc, char **hostname_out,
  41. int *made_connection_pending_out, cached_resolve_t **resolve_out));
  42. MOCK_DECL(STATIC void,send_resolved_cell,(edge_connection_t *conn,
  43. uint8_t answer_type,const cached_resolve_t *resolved));
  44. MOCK_DECL(STATIC void,send_resolved_hostname_cell,(edge_connection_t *conn,
  45. const char *hostname));
  46. cached_resolve_t *dns_get_cache_entry(cached_resolve_t *query);
  47. void dns_insert_cache_entry(cached_resolve_t *new_entry);
  48. MOCK_DECL(STATIC int,
  49. set_exitconn_info_from_resolve,(edge_connection_t *exitconn,
  50. const cached_resolve_t *resolve,
  51. char **hostname_out));
  52. MOCK_DECL(STATIC int,
  53. launch_resolve,(cached_resolve_t *resolve));
  54. #endif /* defined(DNS_PRIVATE) */
  55. #endif /* !defined(TOR_DNS_H) */