-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathdeadwood-3.4.03-min_ttl.patch
More file actions
173 lines (162 loc) · 5.56 KB
/
Copy pathdeadwood-3.4.03-min_ttl.patch
File metadata and controls
173 lines (162 loc) · 5.56 KB
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
diff -ur deadwood-3.4.03/doc/Deadwood.ej deadwood-3.4.04/doc/Deadwood.ej
--- deadwood-3.4.03/doc/Deadwood.ej 2019-02-22 22:26:12.000000000 -0800
+++ deadwood-3.4.04/doc/Deadwood.ej 2022-10-09 06:43:03.136720154 -0700
@@ -361,6 +361,10 @@
<h2>max_tcp_procs</h2>
This is the number of allowed open TCP connections. Default value: 8
+<h2>min_ttl</h2>
+The minimum amount of time we will keep an entry in the cache, in seconds
+(also called "Minimum TTL").
+
<h2>num_retries</h2>
The number of times we retry to send a query upstream
before giving up. If this is 0, we only try once; if this is 1,
diff -ur deadwood-3.4.03/doc/dwood3rc-all deadwood-3.4.04/doc/dwood3rc-all
--- deadwood-3.4.03/doc/dwood3rc-all 2019-02-22 22:26:12.000000000 -0800
+++ deadwood-3.4.04/doc/dwood3rc-all 2022-10-09 06:43:03.140720133 -0700
@@ -65,6 +65,9 @@
# Maximum time an entry will stay in the cache, in seconds (86400 = one day)
max_ttl = 86400
+# Minimum time an entry will stay in the cache in seconds
+min_ttl = 180
+
# The number of times we retry to send a query upstream before giving up.
num_retries = 2
diff -ur deadwood-3.4.03/src/DwMararc.h deadwood-3.4.04/src/DwMararc.h
--- deadwood-3.4.03/src/DwMararc.h 2022-08-03 00:47:08.000000000 -0700
+++ deadwood-3.4.04/src/DwMararc.h 2022-10-09 06:43:16.308650287 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019 Sam Trenholme
+/* Copyright (c) 2007-2022 Sam Trenholme
*
* TERMS
*
@@ -70,13 +70,14 @@
#define DWM_N_reject_ptr 27
#define DWM_N_min_ttl_incomplete_cname 28
#define DWM_N_max_ttl 29
+#define DWM_N_min_ttl 30
/* Number of string parameters in the mararc file */
#define KEY_S_COUNT 7
/* Number of dictionary parameters in the mararc file */
#define KEY_D_COUNT 4
/* Number of numeric parameters in the mararc file */
-#define KEY_N_COUNT 30
+#define KEY_N_COUNT 31
#ifndef MINGW
/* Location of files we read when we run execfile("foo") */
@@ -153,6 +154,7 @@
"min_ttl_incomplete_cname", /* How long to store incomplete CNAME
* records in the cache, in seconds */
"max_ttl", /* Maximum allowed TTL */
+ "min_ttl", /* Minimum allowed TTL */
0 };
#endif /* MARARC_C */
diff -ur deadwood-3.4.03/src/DwRecurse.c deadwood-3.4.04/src/DwRecurse.c
--- deadwood-3.4.03/src/DwRecurse.c 2022-08-03 00:47:08.000000000 -0700
+++ deadwood-3.4.04/src/DwRecurse.c 2022-10-09 06:43:27.464591019 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2015 Sam Trenholme
+/* Copyright (c) 2009-2022 Sam Trenholme
*
* TERMS
*
@@ -50,7 +50,8 @@
extern u_long dont_block;
#endif /* MINGW */
/* Numeric mararc parameters */
-extern int32_t max_ttl;
+extern int_fast32_t max_ttl;
+extern int_fast32_t min_ttl;
/* Maximum number of remote connections */
extern int_fast32_t maxprocs;
@@ -1750,6 +1751,9 @@
this_max_ttl = 30;
}
}
+ if(ttl < min_ttl) {
+ ttl = min_ttl;
+ }
if(ttl > this_max_ttl) {
ttl = this_max_ttl;
}
@@ -2119,9 +2123,12 @@
dw_log_dwstr("Invalid TTL in answer ",answer,100);
ttl = 3600;
}
- if(ttl < 60) {
- ttl = 60;
+ if(ttl < 30) {
+ ttl = 30;
}
+ if(ttl < min_ttl) {
+ ttl = min_ttl;
+ }
if(ttl > max_ttl) {
ttl = max_ttl;
}
@@ -2201,6 +2208,9 @@
if(ttl < 30) {
ttl = 30;
}
+ if(ttl < min_ttl) {
+ ttl = min_ttl;
+ }
if(ttl > max_ttl) {
ttl = max_ttl;
}
diff -ur deadwood-3.4.03/src/DwSocket.c deadwood-3.4.04/src/DwSocket.c
--- deadwood-3.4.03/src/DwSocket.c 2022-08-03 00:47:07.000000000 -0700
+++ deadwood-3.4.04/src/DwSocket.c 2022-10-09 06:43:51.196464665 -0700
@@ -1,5 +1,5 @@
-/* Copyright (c) 2007-2019 Sam Trenholme
- * IPv6 code by Jean-Jacques Sarton
+/* Copyright (c) 2007-2022 Sam Trenholme
+ * IPv6 code by Jean-Jacques Sarton and Sam Trenholme
*
* TERMS
*
@@ -72,6 +72,7 @@
int_fast32_t maradns_uid = 99;
int_fast32_t maradns_gid = 99;
int_fast32_t max_ttl = 86400;
+int_fast32_t min_ttl = 30;
int num_retries = 5;
dwd_dict *blacklist_dict = 0;
@@ -505,6 +506,10 @@
300 /* 5 minutes */,
7776000 /* 90 days */,
86400 /* One day */);
+ min_ttl = get_key_n(DWM_N_min_ttl,
+ 5 /* 5 seconds */,
+ 86400 /* One day */,
+ 60 /* One minute */);
if((num_ports & (num_ports - 1)) != 0) {
dw_fatal("num_ports must be a power of 2");
diff -ur deadwood-3.4.03/src/DwUdpSocket.c deadwood-3.4.04/src/DwUdpSocket.c
--- deadwood-3.4.03/src/DwUdpSocket.c 2022-08-03 00:47:08.000000000 -0700
+++ deadwood-3.4.04/src/DwUdpSocket.c 2022-10-10 14:33:38.766496291 -0700
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2016 Sam Trenholme and others
+/* Copyright (c) 2007-2022 Sam Trenholme and others
*
* TERMS
*
@@ -56,7 +56,8 @@
extern int min_bind;
extern int num_ports;
extern int num_retries;
-extern int32_t max_ttl;
+extern int_fast32_t max_ttl;
+extern int_fast32_t min_ttl;
/* Other mararc parameters */
extern dwd_dict *blacklist_dict;
@@ -872,6 +873,9 @@
if(ttl > max_ttl) {
ttl = max_ttl;
}
+ if(ttl < min_ttl) {
+ ttl = min_ttl;
+ }
/* Routines in DwRecurse.c process the packet and let us know
* what kind of packet we got upstream (so we know how to