tor  master
Functions
dnsserv.c File Reference

Implements client-side DNS proxy server code. More...

#include "or.h"
#include "dnsserv.h"
#include "config.h"
#include "connection.h"
#include "connection_edge.h"
#include "control.h"
#include "main.h"
#include "policies.h"
#include <event2/dns.h>
#include <event2/dns_compat.h>
#include <event2/dns_struct.h>
Include dependency graph for dnsserv.c:

Functions

int dnsserv_launch_request (const char *name, int reverse, control_connection_t *control_conn)
 
void dnsserv_reject_request (entry_connection_t *conn)
 
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)
 

Detailed Description

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.

Function Documentation

◆ dnsserv_close_listener()

void dnsserv_close_listener ( connection_t conn)

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

◆ dnsserv_configure_listener()

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

◆ dnsserv_launch_request()

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.

◆ dnsserv_reject_request()

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.

◆ dnsserv_resolved()

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.