|
Tor 0.5.0.0-alpha-dev
|
Implements client-side DNS proxy server code. More...
#include "core/or/or.h"#include "feature/client/dnsserv.h"#include "app/config/config.h"#include "core/mainloop/connection.h"#include "core/or/connection_edge.h"#include "feature/control/control_events.h"#include "core/mainloop/mainloop.h"#include "core/mainloop/netstatus.h"#include "core/or/policies.h"#include "feature/control/control_connection_st.h"#include "core/or/entry_connection_st.h"#include "core/or/listener_connection_st.h"#include "core/or/socks_request_st.h"#include "lib/evloop/compat_libevent.h"#include <event2/dns.h>#include <event2/dns_compat.h>#include <event2/dns_struct.h>Go to the source code of this file.
Functions | |
| static void | evdns_server_callback (struct evdns_server_request *req, void *data_) |
| int | dnsserv_launch_request (const char *name, int reverse, control_connection_t *control_conn) |
| void | dnsserv_reject_request (entry_connection_t *conn) |
| static const char * | evdns_get_orig_address (const struct evdns_server_request *req, int rtype, const char *addr) |
| void | dnsserv_resolved (entry_connection_t *conn, int answer_type, size_t answer_len, const char *answer, int ttl) |
| void | dnsserv_configure_listener (connection_t *conn) |
| void | dnsserv_close_listener (connection_t *conn) |
Implements client-side DNS proxy server code.
When a user enables the DNSPort configuration option to have their local Tor client handle DNS requests, this module handles it. It functions as a "DNS Server" on the client side, which client applications use.
Inbound DNS requests are represented as entry_connection_t here (since that's how Tor represents client-side streams), which are kept associated with an evdns_server_request structure as exposed by Libevent's evdns code.
Upon receiving a DNS request, libevent calls our evdns_server_callback() function here, which causes this module to create an entry_connection_t request as appropriate. Later, when that request is answered, connection_edge.c calls dnsserv_resolved() so we can finish up and tell the DNS client.
Definition in file dnsserv.c.
| void dnsserv_close_listener | ( | connection_t * | conn | ) |
Free the evdns server port for conn, which must be an AP_DNS_LISTENER.
Definition at line 413 of file dnsserv.c.
Referenced by connection_unregister_events().
| void dnsserv_configure_listener | ( | connection_t * | conn | ) |
Set up the evdns server port for the UDP socket on conn, which must be an AP_DNS_LISTENER
Definition at line 397 of file dnsserv.c.
Referenced by connection_listener_new().
| int dnsserv_launch_request | ( | const char * | name, |
| int | reverse, | ||
| control_connection_t * | control_conn | ||
| ) |
Helper function: called whenever the client sends a resolve request to our controller. We need to eventually answer the request req. Returns 0 if the controller will be getting (or has gotten) an event in response; -1 if we couldn't launch the request.
Definition at line 213 of file dnsserv.c.
Referenced by handle_control_resolve().
| void dnsserv_reject_request | ( | entry_connection_t * | conn | ) |
If there is a pending request on conn that's waiting for an answer, send back an error and free the request.
Definition at line 292 of file dnsserv.c.
Referenced by connection_ap_about_to_close().
| void dnsserv_resolved | ( | entry_connection_t * | conn, |
| int | answer_type, | ||
| size_t | answer_len, | ||
| const char * | answer, | ||
| int | ttl | ||
| ) |
Tell the dns request waiting for an answer on conn that we have an answer of type answer_type (RESOLVE_TYPE_IPV4/IPV6/ERR), of length answer_len, in answer, with TTL ttl. Doesn't do any caching; that's handled elsewhere.
Definition at line 343 of file dnsserv.c.
Referenced by connection_ap_handshake_socks_resolved().
|
static |
Look up the original name that corresponds to 'addr' in req. We use this to preserve case in order to facilitate clients using 0x20-hacks to avoid DNS poisoning.
Definition at line 305 of file dnsserv.c.
Referenced by dnsserv_resolved().
|
static |
Helper function: called by evdns whenever the client sends a request to our DNSPort. We need to eventually answer the request req.
Definition at line 49 of file dnsserv.c.
Referenced by dnsserv_configure_listener().