~ubuntu-branches/ubuntu/trusty/maradns/trusty-proposed

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
--- deadwood-2.9.03/src/DwSocket.c.orig	2010-08-06 05:50:57.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.c	2010-08-06 06:05:48.000000000 -0700
@@ -826,6 +826,8 @@
                    dw_put_u16(packet,1,-1) == -1 /* QCLASS: 1 */) {
                         goto catch_handle_expired;
                 }
+		dw_log_dwstr_str("Connection for query ",rem[a].query,
+				" did not respond; trying again",128);
                 make_remote_connection(a,(unsigned char *)packet->str,
                                 packet->len,rem[a].query,INVALID_SOCKET);
                 rem[a].die = get_time() + ((int64_t)timeout_seconds << 8);
--- deadwood-2.9.03/src/DwUdpSocket.c.orig	2010-08-06 06:06:03.000000000 -0700
+++ deadwood-2.9.03/src/DwUdpSocket.c	2010-08-06 06:07:02.000000000 -0700
@@ -197,6 +197,7 @@
 
         /* Get IP of remote server and open a socket to them */
         addr = get_upstream_ip(query,n);
+	dw_log_ip("Making connection to IP",&addr,128);
         if(addr.len == 0) { /* Failed to get upstream IP */
                 return;
         } else if(addr.len == 4 || addr.len == 16) { /* IPv4/IPv6 IP */
--- deadwood-2.9.03/src/DwSocket.h.orig	2010-07-29 10:39:10.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.h	2010-08-06 06:23:14.000000000 -0700
@@ -39,7 +39,6 @@
 
 #include "DwStr.h"
 #include "DwMararc.h"
-#include "DwSys.h"
 #include "DwStr_functions.h"
 #include "DwRadioGatun.h"
 #include "DwHash.h"
@@ -99,6 +98,8 @@
         uint8_t flags;
 } ip_addr_T;
 
+#include "DwSys.h" /* DwSys.h needs ip_addr_t */
+
 /* Structure for storing an IP address *and* a netmask; note that the
  * beginning of the structure *must* have the exact same form as the
  * ip_addr_T structure above */
--- deadwood-2.9.03/src/DwSocket.h.orig	2010-08-06 06:38:16.000000000 -0700
+++ deadwood-2.9.03/src/DwSocket.h	2010-08-06 06:38:50.000000000 -0700
@@ -54,7 +54,9 @@
 #include <grp.h>
 #else  /* MINGW */
 /* Maximum number of open sockets; make this big like it is in *NIX */
+#ifndef FD_SETSIZE
 #define FD_SETSIZE 512
+#endif /* FD_SETSIZE */
 #include <winsock.h>
 #include <wininet.h>
 #endif /* MINGW */
--- deadwood-2.9.03/src/DwSys.h.orig	2010-08-06 06:40:52.000000000 -0700
+++ deadwood-2.9.03/src/DwSys.h	2010-08-06 06:41:24.000000000 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2009 Sam Trenholme
+/* Copyright (c) 2007-2010 Sam Trenholme
  *
  * TERMS
  *
@@ -16,14 +16,18 @@
  * fitness for purpose.
  */
 
+#ifndef __DWSYS_H_DEFINED__
+#define __DWSYS_H_DEFINED__
+
+#ifndef MINGW
+#include <grp.h>
+#endif /* MINGW */
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
-#ifndef MINGW
-#include <grp.h>
-#endif /* MINGW */
+#include "DwSocket.h"
 
 /* Parameters that are currently hardcoded in the source code (This will
  * change once we get something very basic that works) */
@@ -47,6 +51,9 @@
 /* Close the log */
 void dw_log_close();
 
+/* Log a char followed by an IP */
+void dw_log_ip(char *string, ip_addr_T *ip, int min_log_level);
+
 /* Log a string followed by the contents of a DwStr object */
 void dw_log_dwstr(char *s1, dw_str *s2, int min_log_level);
 
@@ -139,3 +146,5 @@
  * the def value */
 int32_t get_key_n(int32_t get, int32_t min, int32_t max, int32_t def);
 
+#endif /* __DWSYS_H_DEFINED__ */
+
--- deadwood-2.9.03/src/DwSys.c.orig	2010-08-06 08:02:05.000000000 -0700
+++ deadwood-2.9.03/src/DwSys.c	2010-08-06 08:03:09.000000000 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2009 Sam Trenholme
+/* Copyright (c) 2007-2010 Sam Trenholme
  *
  * TERMS
  *
@@ -126,6 +126,80 @@
         }
 }
 
+/* Log an IP; private */
+void dw_log_ip_p(ip_addr_T *ip) {
+	int counter = 0;
+
+	if(ip == 0) {
+#ifndef MINGW
+		printf("%s","(null IP)\n");
+#else /* MINGW */
+		fprintf(LOG,"%s","(null IP)\n");
+#endif /* MINGW */
+		return;
+	}
+
+	if(ip->len == 4) {
+		for(counter = 0; counter < 3; counter++) {
+#ifndef MINGW
+			printf("%d.",ip->ip[counter]);
+#else /* MINGW */
+			fprintf(LOG,"%d.",ip->ip[counter]);
+#endif /* MINGW */
+		}
+#ifndef MINGW
+		printf("%d ",ip->ip[3]);
+#else /* MINGW */
+		fprintf(LOG,"%d ",ip->ip[3]);
+#endif /* MINGW */
+#ifdef IPV6
+	} else if(ip->len == 16) {
+		for(counter = 0; counter < 15; counter++) {
+#ifndef MINGW
+			printf("%02x:",ip->ip[counter]);
+#else /* MINGW */
+			fprintf(LOG,"%02x:",ip->ip[counter]);
+#endif /* MINGW */
+		}
+#ifndef MINGW
+		printf("%02x ",ip->ip[15]);
+#else /* MINGW */
+		fprintf(LOG,"%02x ",ip->ip[15]);
+#endif /* MINGW */
+#endif /* IPV6 */
+	} else {
+#ifndef MINGW
+		printf("%s%d","IP of length ",ip->len);
+#else /* MINGW */
+		fprintf(LOG,"%s%d","IP of length ",ip->len);
+#endif /* MINGW */
+	}
+}		
+
+/* Log a char followed by an IP */
+void dw_log_ip(char *string, ip_addr_T *ip, int min_log_level) {
+        int32_t ll = key_n[DWM_N_verbose_level];
+        if(ll <= 0 || ll < min_log_level) {
+                return;
+        }
+
+#ifndef MINGW
+        printf("%s ",string);
+#else /* MINGW */
+        dw_win_time();
+        fprintf(LOG,"%s ",string);
+#endif /* MINGW */
+
+	dw_log_ip_p(ip);
+
+#ifndef MINGW
+        printf("%s","\n");
+#else /* MINGW */
+        fprintf(LOG,"%s","\n");
+#endif /* MINGW */
+	
+}
+
 /* Log a string followed by the contents of a DwStr object */
 void dw_log_dwstr(char *s1, dw_str *s2, int min_log_level) {
         int32_t ll = key_n[DWM_N_verbose_level];