1
If there was a glueless NS record, Deadwood started processing the NS
2
referral, but sent a server fail to the DNS thingy (instead of sending
3
nothing until the NS record is worked out).
7
diff --git a/deadwood-github/src/DwSocket.h b/deadwood-github/src/DwSocket.h
8
index f07f150..4722361 100644
9
--- a/deadwood-github/src/DwSocket.h
10
+++ b/deadwood-github/src/DwSocket.h
11
@@ -317,7 +317,7 @@ dw_str *make_dns_packet(dw_str *question, dw_str *answer, int32_t id);
13
/* Given a remote number, a C-string with the packet to send them, and
14
* the length of that string, make a connection to a remote server */
15
-void make_remote_connection(int32_t n, unsigned char *packet, int len,
16
+int make_remote_connection(int32_t n, unsigned char *packet, int len,
17
dw_str *query, SOCKET x_socket_num);
19
/* Forward a remote reply back to the client */
20
diff --git a/deadwood-github/src/DwUdpSocket.c b/deadwood-github/src/DwUdpSocket.c
21
index 16f3242..d11f5d6 100644
22
--- a/deadwood-github/src/DwUdpSocket.c
23
+++ b/deadwood-github/src/DwUdpSocket.c
24
@@ -176,7 +176,7 @@ SOCKET setup_server(sockaddr_all_T *server, ip_addr_T *addr) {
26
/* Given a remote number, a C-string with the packet to send them, and
27
* the length of that string, make a connection to a remote server */
28
-void make_remote_connection(int32_t n, unsigned char *packet, int len,
29
+int make_remote_connection(int32_t n, unsigned char *packet, int len,
30
dw_str *query, SOCKET x_socket_num) {
31
sockaddr_all_T server;
33
@@ -187,13 +187,13 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
35
if(rem[n].socket != x_socket_num || /* Already used (sanity check) */
36
rem[n].recurse_depth > 32) { /* Infinite recursion protection */
41
/* Get a random query ID to send to the remote server */
42
rnum = set_dns_qid(packet,len,dwr_rng(rng_seed));
48
/* Get IP of remote server and open a socket to them */
49
@@ -211,15 +211,15 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
51
dw_log_ip("Making connection to IP",&addr,128);
52
if(addr.len == 0) { /* Failed to get upstream IP */
55
} else if(addr.len == 4 || addr.len == 16) { /* IPv4/IPv6 IP */
56
s = setup_server(&server,&addr);
57
} else if(addr.glueless != 0) { /* Glueless NS referral */
58
dwx_do_ns_glueless(addr,n);
62
if(s == INVALID_SOCKET) { /* Failed to make socket */
68
@@ -234,7 +234,7 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
69
(connect(s, (struct sockaddr *)&server, inet_len) == -1) ||
70
(send(s,packet,len,0) < 0)) {
76
/* OK, now note the pending connection */
77
@@ -244,6 +244,7 @@ void make_remote_connection(int32_t n, unsigned char *packet, int len,
80
rem[n].remote_id = rnum;
84
/* Send a server failure back to the client when the server is overloaded.
85
@@ -324,21 +325,24 @@ void zap_inflight(dw_str *query) {
88
/* Make a new UDP connection on remote pending connection b */
89
-void make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
90
+int make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
91
dw_str *answer = 0, *check = 0;
93
+ int counter = 0, z = 0;
95
/* Make a new remote connection */
96
if(rem[b].socket != INVALID_SOCKET) { /* Sanity check */
100
rem[b].query = dw_get_dname_type(a,12,len);
101
dwc_lower_case(rem[b].query);
102
rem[b].local = dw_malloc(num_alloc * sizeof(local_T *));
103
if(rem[b].local == 0) {
107
- make_remote_connection(b,a,len,rem[b].query,INVALID_SOCKET);
108
+ z = make_remote_connection(b,a,len,rem[b].query,INVALID_SOCKET);
113
for(counter = 0; counter < num_alloc; counter++) {
114
rem[b].local[counter] = 0;
115
@@ -355,6 +359,7 @@ void make_new_udp_connect(int b, unsigned char *a, int len, int num_alloc) {
122
/* Send a local DNS request to the upstream (remote) server; this
123
@@ -382,7 +387,9 @@ int forward_local_udp_packet(SOCKET sock, int32_t local_id,
125
} else { /* Create new connection */
127
- make_new_udp_connect(b,a,len,num_alloc);
128
+ if(make_new_udp_connect(b,a,len,num_alloc) == 2) {
132
} else { /* Add new local to already inflight connection */
133
if(rem[b].num_locals >= num_alloc - 2) {