dnsserv.c File Reference

Implements client-side DNS proxy server code. Note: this is the DNS Server code, not the Server DNS code. Confused? This code runs on client-side, and acts as a DNS server. The code in dns.c, on the other hand, runs on Tor servers, and acts as a DNS client. More...

#include "or.h"
#include "eventdns.h"

Functions

static void evdns_server_callback (struct evdns_server_request *req, void *_data)
int dnsserv_launch_request (const char *name, int reverse)
void dnsserv_reject_request (edge_connection_t *conn)
static const char * evdns_get_orig_address (const struct evdns_server_request *req, int rtype, const char *addr)
void dnsserv_resolved (edge_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)


Detailed Description

Implements client-side DNS proxy server code. Note: this is the DNS Server code, not the Server DNS code. Confused? This code runs on client-side, and acts as a DNS server. The code in dns.c, on the other hand, runs on Tor servers, and acts as a DNS client.


Function Documentation

void dnsserv_close_listener ( connection_t conn  ) 

Free the evdns server port for conn, which must be an AP_DNS_LISTENER.

References CONN_TYPE_AP_DNS_LISTENER, connection_t::dns_server_port, tor_assert, and connection_t::type.

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

References CONN_TYPE_AP_DNS_LISTENER, connection_t::dns_server_port, evdns_server_callback(), connection_t::s, tor_assert, and connection_t::type.

Referenced by connection_create_listener().

int dnsserv_launch_request ( const char *  name,
int  reverse 
)

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.

References edge_connection_t::_base, socks_request_t::address, AP_CONN_STATE_RESOLVE_WAIT, socks_request_t::command, CONN_TYPE_AP, connection_add(), connection_ap_handshake_rewrite_and_attach(), connection_free(), edge_connection_new(), escaped_safe_str_client(), edge_connection_t::is_dns_request, LD_APP, SOCKS_COMMAND_RESOLVE, SOCKS_COMMAND_RESOLVE_PTR, edge_connection_t::socks_request, connection_t::state, TO_CONN, and tor_free.

Referenced by handle_control_resolve().

void dnsserv_reject_request ( edge_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.

References edge_connection_t::dns_server_request.

Referenced by connection_about_to_close_connection().

void dnsserv_resolved ( edge_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.

References socks_request_t::address, socks_request_t::command, edge_connection_t::dns_server_request, evdns_get_orig_address(), LD_APP, SOCKS_COMMAND_RESOLVE, SOCKS_COMMAND_RESOLVE_PTR, edge_connection_t::socks_request, and tor_free.

Referenced by connection_ap_handshake_socks_resolved().

static const char* evdns_get_orig_address ( const struct evdns_server_request *  req,
int  rtype,
const char *  addr 
) [static]

Look up the original name that corresponds to 'addr' in req. We use this to preserve case in order to facilitate people using 0x20-hacks to avoid DNS poisoning.

References tor_fragile_assert.

Referenced by dnsserv_resolved().

static void evdns_server_callback ( struct evdns_server_request *  req,
void *  _data 
) [static]


Generated on Tue May 25 00:30:44 2010 for tor by  doxygen 1.5.6