dns.h 2.3 KB

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