|
@@ -2,7 +2,7 @@
|
2
|
2
|
* (c) Copyright 2005 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
|
3
|
3
|
*
|
4
|
4
|
* This source code is free software; you can redistribute it and/or
|
5
|
|
- * modify it under the terms of the GNU General Public License as published
|
|
5
|
+ * modify it under the terms of the GNU General Public License as published
|
6
|
6
|
* by the Free Software Foundation; either version 2 of the License,
|
7
|
7
|
* or (at your option) any later version.
|
8
|
8
|
*
|
|
@@ -20,7 +20,7 @@
|
20
|
20
|
*
|
21
|
21
|
* The DNS wrapper listens to the port 53 for DNS hostname resolution queries,
|
22
|
22
|
* it then resolves the hostname by using the ANDNA system and sends back the
|
23
|
|
- * resolved ip. In this way, every program can use ANDNA: just set
|
|
23
|
+ * resolved ip. In this way, every program can use ANDNA: just set
|
24
|
24
|
* "nameserver localhost"
|
25
|
25
|
* in /etc/resolv.conf ;)
|
26
|
26
|
*/
|
|
@@ -49,7 +49,7 @@
|
49
|
49
|
|
50
|
50
|
/*
|
51
|
51
|
* dns_exec_pkt: resolve the hostname contained in the DNS query and sends
|
52
|
|
- * the reply to from.
|
|
52
|
+ * the reply to from.
|
53
|
53
|
* `passed_argv' is a pointer to a dns_exec_pkt_argv struct.
|
54
|
54
|
*/
|
55
|
55
|
void *dns_exec_pkt(void *passed_argv)
|
|
@@ -77,6 +77,7 @@ void *dns_exec_pkt(void *passed_argv)
|
77
|
77
|
/* Send the DNS reply */
|
78
|
78
|
bytes_sent=inet_sendto(argv.sk, answer_buffer, answer_length, 0,
|
79
|
79
|
&argv.from, argv.from_len);
|
|
80
|
+ error("bytes_sent is: %d argv.sk is: %d answer_buffer is: %s answer_length is: %d argv.from is: %p agrv.from_len is: %p", bytes_sent,argv.sk, answer_buffer, answer_length, argv.from, argv.from_len);
|
80
|
81
|
if(bytes_sent != answer_length)
|
81
|
82
|
debug(DBG_SOFT, ERROR_MSG "inet_sendto error: %s", ERROR_POS,
|
82
|
83
|
strerror(errno));
|
|
@@ -103,7 +104,7 @@ void dns_wrapper_daemon(u_short port)
|
103
|
104
|
#ifdef DEBUG
|
104
|
105
|
int select_errors=0;
|
105
|
106
|
#endif
|
106
|
|
-
|
|
107
|
+
|
107
|
108
|
pthread_attr_init(&t_attr);
|
108
|
109
|
pthread_attr_setdetachstate(&t_attr, PTHREAD_CREATE_DETACHED);
|
109
|
110
|
pthread_mutex_init(&dns_exec_lock, 0);
|
|
@@ -117,10 +118,10 @@ void dns_wrapper_daemon(u_short port)
|
117
|
118
|
for(;;) {
|
118
|
119
|
if(!sk)
|
119
|
120
|
fatal("The dns_wrapper_daemon socket got corrupted");
|
120
|
|
-
|
|
121
|
+
|
121
|
122
|
FD_ZERO(&fdset);
|
122
|
123
|
FD_SET(sk, &fdset);
|
123
|
|
-
|
|
124
|
+
|
124
|
125
|
ret = select(sk+1, &fdset, NULL, NULL, NULL);
|
125
|
126
|
if(sigterm_timestamp)
|
126
|
127
|
/* NetsukukuD has been closed */
|
|
@@ -131,7 +132,7 @@ void dns_wrapper_daemon(u_short port)
|
131
|
132
|
break;
|
132
|
133
|
select_errors++;
|
133
|
134
|
#endif
|
134
|
|
- error("dns_wrapper_daemonp: select error: %s",
|
|
135
|
+ error("dns_wrapper_daemonp: select error: %s",
|
135
|
136
|
strerror(errno));
|
136
|
137
|
continue;
|
137
|
138
|
}
|
|
@@ -141,7 +142,7 @@ void dns_wrapper_daemon(u_short port)
|
141
|
142
|
setzero(&buf, MAX_DNS_PKT_SZ);
|
142
|
143
|
setzero(&exec_pkt_argv.from, sizeof(struct sockaddr));
|
143
|
144
|
setzero(&exec_pkt_argv, sizeof(struct dns_exec_pkt_argv));
|
144
|
|
-
|
|
145
|
+
|
145
|
146
|
exec_pkt_argv.from_len = my_family == AF_INET ?
|
146
|
147
|
sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
|
147
|
148
|
|
|
@@ -153,14 +154,14 @@ void dns_wrapper_daemon(u_short port)
|
153
|
154
|
" query pkt aborted!");
|
154
|
155
|
continue;
|
155
|
156
|
}
|
156
|
|
-
|
|
157
|
+
|
157
|
158
|
/* Exec the pkt in another thread */
|
158
|
159
|
exec_pkt_argv.sk=sk;
|
159
|
160
|
exec_pkt_argv.rpkt_sz=err;
|
160
|
161
|
exec_pkt_argv.rpkt=buf;
|
161
|
|
-
|
|
162
|
+
|
162
|
163
|
pthread_mutex_lock(&dns_exec_lock);
|
163
|
|
- pthread_create(&thread, &t_attr, dns_exec_pkt,
|
|
164
|
+ pthread_create(&thread, &t_attr, dns_exec_pkt,
|
164
|
165
|
(void *)&exec_pkt_argv);
|
165
|
166
|
pthread_mutex_lock(&dns_exec_lock);
|
166
|
167
|
pthread_mutex_unlock(&dns_exec_lock);
|