1 |
pcg |
1.1 |
/* |
2 |
|
|
vpn_dns.C -- handle the dns tunnel part of the protocol. |
3 |
|
|
Copyright (C) 2003-2004 Marc Lehmann <pcg@goof.com> |
4 |
|
|
|
5 |
|
|
This program is free software; you can redistribute it and/or modify |
6 |
|
|
it under the terms of the GNU General Public License as published by |
7 |
|
|
the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
(at your option) any later version. |
9 |
|
|
|
10 |
|
|
This program is distributed in the hope that it will be useful, |
11 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
GNU General Public License for more details. |
14 |
|
|
|
15 |
|
|
You should have received a copy of the GNU General Public License |
16 |
|
|
along with this program; if not, write to the Free Software |
17 |
|
|
Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
#include "config.h" |
21 |
|
|
|
22 |
|
|
#if ENABLE_DNS |
23 |
|
|
|
24 |
|
|
// dns processing is EXTREMELY ugly. For obvious(?) reasons. |
25 |
|
|
// it's a hack, use only in emergency situations please. |
26 |
|
|
|
27 |
|
|
#include <cstring> |
28 |
|
|
|
29 |
|
|
#include <sys/types.h> |
30 |
|
|
#include <sys/socket.h> |
31 |
|
|
#include <sys/wait.h> |
32 |
|
|
#include <sys/uio.h> |
33 |
|
|
#include <errno.h> |
34 |
|
|
#include <time.h> |
35 |
|
|
#include <unistd.h> |
36 |
|
|
#include <fcntl.h> |
37 |
|
|
|
38 |
|
|
#include <map> |
39 |
|
|
|
40 |
|
|
#include "netcompat.h" |
41 |
|
|
|
42 |
|
|
#include "vpn.h" |
43 |
|
|
|
44 |
|
|
#if ENABLE_HTTP_PROXY |
45 |
|
|
# include "conf.h" |
46 |
|
|
#endif |
47 |
|
|
|
48 |
|
|
#define MIN_RETRY 1. |
49 |
|
|
#define MAX_RETRY 60. |
50 |
|
|
|
51 |
|
|
#define SERVER conf.dns_port |
52 |
|
|
|
53 |
|
|
/* |
54 |
|
|
|
55 |
|
|
protocol, in shorthand :) |
56 |
|
|
|
57 |
|
|
<cseqno> ANY? poll for more data |
58 |
|
|
=> TXT <sseqno><data> |
59 |
|
|
<cseqno><data> TXT? send more data |
60 |
|
|
=> TXT <empty> |
61 |
|
|
|
62 |
|
|
sequence numbers are 12 bit, 9 bit packet-number and 3 bit fragment id (7 |
63 |
|
|
- id, actually) last fragment is sent first, however |
64 |
|
|
|
65 |
|
|
*/ |
66 |
|
|
|
67 |
|
|
void |
68 |
|
|
vpn::dnsv4_ev (io_watcher &w, short revents) |
69 |
|
|
{ |
70 |
|
|
if (revents & EVENT_READ) |
71 |
|
|
{ |
72 |
|
|
struct sockaddr_in sa; |
73 |
|
|
socklen_t sa_len = sizeof (sa); |
74 |
|
|
int len; |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
bool |
79 |
|
|
vpn::send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) |
80 |
|
|
{ |
81 |
|
|
//return i->send_packet (pkt, tos); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
#endif |
85 |
|
|
|