forked from semigodking/redsocks
-
Notifications
You must be signed in to change notification settings - Fork 5
/
tcpdns.h
53 lines (46 loc) · 1.32 KB
/
tcpdns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef TCPDNS_H
#define TCPDNS_H
typedef struct tcpdns_config_t {
struct sockaddr_in bindaddr;
struct sockaddr_in udpdns1_addr;
struct sockaddr_in udpdns2_addr;
struct sockaddr_in tcpdns1_addr;
struct sockaddr_in tcpdns2_addr;
uint16_t timeout; /* timeout value for DNS response*/
} tcpdns_config;
typedef struct tcpdns_instance_t {
list_head list;
tcpdns_config config;
struct event * listener;
list_head requests;
// Data for DNS resolver status tracking/checking
int udp1_delay_ms;
int udp2_delay_ms;
int tcp1_delay_ms;
int tcp2_delay_ms;
} tcpdns_instance;
typedef struct dns_header_t {
uint16_t id;
uint8_t qr_opcode_aa_tc_rd;
uint8_t ra_z_rcode;
uint16_t qdcount;
uint16_t ancount;
uint16_t nscount;
uint16_t arcount;
} PACKED dns_header;
typedef struct dns_request_t {
list_head list;
tcpdns_instance * instance;
short state;
int flags;
struct bufferevent* resolver;
struct sockaddr_in client_addr;
struct timeval req_time;
int * delay;
size_t data_len;
union {
char raw[513]; // DNS request longer than 512 should go over TCP.
dns_header header;
} data;
} dns_request;
#endif /* TCPDNS_H */