This is the main file of the tdns authoritative server. More...
#include <cstdint>
#include <vector>
#include <map>
#include <stdexcept>
#include "sclasses.hh"
#include <thread>
#include <signal.h>
#include "record-types.hh"
#include "dns-storage.hh"
#include "tdnssec.hh"
Functions | |
void | addAdditional (const DNSNode *bestzone, const DNSName &zone, const vector< DNSName > &toresolve, DNSMessageWriter &response) |
Looks up additional records. More... | |
bool | processQuestion (const DNSNode &zones, DNSMessageReader &dm, const ComboAddress &remote, DNSMessageWriter &response) |
This is the main DNS logic function. More... | |
void | udpThread (ComboAddress local, Socket *sock, const DNSNode *zones) |
uint16_t | tcpGetLen (int sock) |
void | tcpClientThread (ComboAddress remote, int s, const DNSNode *zones) |
std::unique_ptr< DNSNode > | retrieveZone (const ComboAddress &remote, const DNSName &zone) |
connects to an authoritative server, retrieves a zone, returns it as a smart pointer More... | |
int | main (int argc, char **argv) |
This is the main tdns function. More... | |
This is the main file of the tdns authoritative server.
void addAdditional | ( | const DNSNode * | bestzone, |
const DNSName & | zone, | ||
const vector< DNSName > & | toresolve, | ||
DNSMessageWriter & | response | ||
) |
Looks up additional records.
This function is called to do additional processing on records we encountered earlier that would benefit. This includes MX and NS records.
Note that this function will only ook within 'bestzone', the best zone we had for the original query. This means we will not look at potentially helpful records in other zones. RFCs tell us that resolvers should not use/trust such out of zone data anyhow, but no RFC tells us we should not add that data.
But we don't
int main | ( | int | argc, |
char ** | argv | ||
) |
This is the main tdns function.
bool processQuestion | ( | const DNSNode & | zones, |
DNSMessageReader & | dm, | ||
const ComboAddress & | remote, | ||
DNSMessageWriter & | response | ||
) |
This is the main DNS logic function.
This is the main 'DNS logic' function. It receives a set of zones, a readable DNS query from a certain IP address, and a writable DNS response.
This function is called by both UDP and TCP listeners. It therefore does not do any IXFR/AXFR. It does however perform several sanity checks.
Returns false if no response should be sent.
This function implements "the algorithm" from RFC 1034 and is key to unstanding DNS
connects to an authoritative server, retrieves a zone, returns it as a smart pointer
void tcpClientThread | ( | ComboAddress | remote, |
int | s, | ||
const DNSNode * | zones | ||
) |
spawned for each new TCP/IP client. In actual production this is not a good idea.
uint16_t tcpGetLen | ( | int | sock | ) |
helper to read a 16 bit length in network order. Returns 0 on EOF
void udpThread | ( | ComboAddress | local, |
Socket * | sock, | ||
const DNSNode * | zones | ||
) |