2010-07-22 12:24:25 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2018-06-20 14:13:28 +02:00
|
|
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
2010-07-22 12:24:25 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file dns.h
|
|
|
|
* \brief Header file for dns.c.
|
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_DNS_H
|
|
|
|
#define TOR_DNS_H
|
2010-07-22 12:24:25 +02:00
|
|
|
|
2017-01-02 20:55:39 +01:00
|
|
|
/** Lowest value for DNS ttl that a server will give. */
|
|
|
|
#define MIN_DNS_TTL_AT_EXIT (5*60)
|
|
|
|
/** Highest value for DNS ttl that a server will give. */
|
|
|
|
#define MAX_DNS_TTL_AT_EXIT (60*60)
|
|
|
|
|
|
|
|
/** How long do we keep DNS cache entries before purging them (regardless of
|
|
|
|
* their TTL)? */
|
|
|
|
#define MAX_DNS_ENTRY_AGE (3*60*60)
|
|
|
|
/** How long do we cache/tell clients to cache DNS records when no TTL is
|
|
|
|
* known? */
|
|
|
|
#define DEFAULT_DNS_TTL (30*60)
|
|
|
|
|
2010-07-22 12:24:25 +02:00
|
|
|
int dns_init(void);
|
|
|
|
int has_dns_init_failed(void);
|
|
|
|
void dns_free_all(void);
|
|
|
|
uint32_t dns_clip_ttl(uint32_t ttl);
|
|
|
|
int dns_reset(void);
|
|
|
|
void connection_dns_remove(edge_connection_t *conn);
|
|
|
|
void assert_connection_edge_not_dns_pending(edge_connection_t *conn);
|
|
|
|
void assert_all_pending_dns_resolves_ok(void);
|
2015-07-22 15:46:44 +02:00
|
|
|
MOCK_DECL(void,dns_cancel_pending_resolve,(const char *question));
|
2010-07-22 12:24:25 +02:00
|
|
|
int dns_resolve(edge_connection_t *exitconn);
|
|
|
|
void dns_launch_correctness_checks(void);
|
|
|
|
int dns_seems_to_be_broken(void);
|
2012-10-27 22:34:49 +02:00
|
|
|
int dns_seems_to_be_broken_for_ipv6(void);
|
2010-07-22 12:24:25 +02:00
|
|
|
void dns_reset_correctness_checks(void);
|
|
|
|
void dump_dns_mem_usage(int severity);
|
|
|
|
|
2015-07-22 15:46:44 +02:00
|
|
|
#ifdef DNS_PRIVATE
|
2018-07-05 22:34:59 +02:00
|
|
|
#include "feature/relay/dns_structs.h"
|
2015-07-22 15:46:44 +02:00
|
|
|
|
|
|
|
MOCK_DECL(STATIC int,dns_resolve_impl,(edge_connection_t *exitconn,
|
|
|
|
int is_resolve,or_circuit_t *oncirc, char **hostname_out,
|
|
|
|
int *made_connection_pending_out, cached_resolve_t **resolve_out));
|
|
|
|
|
|
|
|
MOCK_DECL(STATIC void,send_resolved_cell,(edge_connection_t *conn,
|
|
|
|
uint8_t answer_type,const cached_resolve_t *resolved));
|
|
|
|
|
|
|
|
MOCK_DECL(STATIC void,send_resolved_hostname_cell,(edge_connection_t *conn,
|
|
|
|
const char *hostname));
|
2015-10-18 17:04:48 +02:00
|
|
|
|
|
|
|
cached_resolve_t *dns_get_cache_entry(cached_resolve_t *query);
|
|
|
|
void dns_insert_cache_entry(cached_resolve_t *new_entry);
|
|
|
|
|
2015-10-20 19:40:21 +02:00
|
|
|
MOCK_DECL(STATIC int,
|
|
|
|
set_exitconn_info_from_resolve,(edge_connection_t *exitconn,
|
|
|
|
const cached_resolve_t *resolve,
|
|
|
|
char **hostname_out));
|
|
|
|
|
2015-10-21 21:24:00 +02:00
|
|
|
MOCK_DECL(STATIC int,
|
|
|
|
launch_resolve,(cached_resolve_t *resolve));
|
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* defined(DNS_PRIVATE) */
|
2015-07-22 15:46:44 +02:00
|
|
|
|
2017-09-15 22:24:44 +02:00
|
|
|
#endif /* !defined(TOR_DNS_H) */
|
2010-07-22 12:24:25 +02:00
|
|
|
|