Added debug capability on server

This commit is contained in:
Erik Ekman 2008-08-05 22:37:40 +00:00
parent 2ab94a7991
commit 9fa70acc69
3 changed files with 33 additions and 4 deletions

View File

@ -17,6 +17,8 @@ CHANGES:
- Fixed bug #21, now only IP address part of each packet is checked. - Fixed bug #21, now only IP address part of each packet is checked.
Should remove the need for the -c option and also work with Should remove the need for the -c option and also work with
bugfixed DNS servers worldwide. bugfixed DNS servers worldwide.
- Added -D option on server to enable debugging. Debug level 1 now prints
info about each RX/TX datagram.
2007-11-30: 0.4.1 "Tea Online" 2007-11-30: 0.4.1 "Tea Online"
- Introduced encoding API - Introduced encoding API

View File

@ -25,7 +25,7 @@ iodine, iodined \- tunnel IPv4 over DNS
.B iodined [-h] .B iodined [-h]
.B iodined [-c] [-s] [-f] [-u .B iodined [-c] [-s] [-f] [-D] [-u
.I user .I user
.B ] [-P .B ] [-P
.I password .I password
@ -79,13 +79,15 @@ and otherwise tunX.
.SS Server Options: .SS Server Options:
.TP .TP
.B -c .B -c
Disable checks on client IP and port on all incoming requests. Disable checks on client IP on all incoming requests.
This might help if server is behind a NAT firewall.
.TP .TP
.B -s .B -s
Don't try to configure IP address or MTU. This should only be used if Don't try to configure IP address or MTU. This should only be used if
you have already configured the device that will be used. you have already configured the device that will be used.
.TP .TP
.B -D
Increase debug level. Level 1 prints info about each RX/TX packet.
.TP
.B -m mtu .B -m mtu
Set 'mtu' as mtu size for the tunnel device. This will be sent to the client Set 'mtu' as mtu size for the tunnel device. This will be sent to the client
on connect, and the client will use the same mtu. on connect, and the client will use the same mtu.

View File

@ -57,6 +57,8 @@ static int check_ip;
static int my_mtu; static int my_mtu;
static in_addr_t my_ip; static in_addr_t my_ip;
static int debug;
#if !defined(BSD) && !defined(__GLIBC__) #if !defined(BSD) && !defined(__GLIBC__)
static char *__progname; static char *__progname;
#endif #endif
@ -328,6 +330,12 @@ tunnel_dns(int tun_fd, int dns_fd)
if ((read = read_dns(dns_fd, &q)) <= 0) if ((read = read_dns(dns_fd, &q)) <= 0)
return 0; return 0;
if (debug >= 1) {
struct sockaddr_in *tempin;
tempin = (struct sockaddr_in *) &(q.from);
printf("RX: client %s, type %d, name %s\n", inet_ntoa(tempin->sin_addr), q.type, q.name);
}
switch (q.type) { switch (q.type) {
case T_NULL: case T_NULL:
handle_null_request(tun_fd, dns_fd, &q); handle_null_request(tun_fd, dns_fd, &q);
@ -427,6 +435,13 @@ write_dns(int fd, struct query *q, char *data, int datalen)
len = dns_encode(buf, sizeof(buf), q, QR_ANSWER, data, datalen); len = dns_encode(buf, sizeof(buf), q, QR_ANSWER, data, datalen);
if (debug >= 1) {
struct sockaddr_in *tempin;
tempin = (struct sockaddr_in *) &(q->from);
printf("TX: client %s, type %d, name %s, %d bytes data\n",
inet_ntoa(tempin->sin_addr), q->type, q->name, datalen);
}
sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen); sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen);
} }
@ -499,6 +514,7 @@ main(int argc, char **argv)
port = 53; port = 53;
check_ip = 1; check_ip = 1;
skipipconfig = 0; skipipconfig = 0;
debug = 0;
b32 = get_base32_encoder(); b32 = get_base32_encoder();
@ -513,7 +529,7 @@ main(int argc, char **argv)
memset(password, 0, sizeof(password)); memset(password, 0, sizeof(password));
srand(time(NULL)); srand(time(NULL));
while ((choice = getopt(argc, argv, "vcsfhu:t:d:m:l:p:P:")) != -1) { while ((choice = getopt(argc, argv, "vcsfhDu:t:d:m:l:p:P:")) != -1) {
switch(choice) { switch(choice) {
case 'v': case 'v':
version(); version();
@ -530,6 +546,9 @@ main(int argc, char **argv)
case 'h': case 'h':
help(); help();
break; break;
case 'D':
debug++;
break;
case 'u': case 'u':
username = optarg; username = optarg;
break; break;
@ -605,6 +624,12 @@ main(int argc, char **argv)
printf("You must manually forward port 53 to port %d for things to work.\n", port); printf("You must manually forward port 53 to port %d for things to work.\n", port);
} }
if (debug) {
printf("Debug level %d enabled, will stay in foreground.\n", debug);
printf("Add more -D switches to set higher debug level.\n");
foreground = 1;
}
if (listen_ip == INADDR_NONE) { if (listen_ip == INADDR_NONE) {
warnx("Bad IP address to listen on.\n"); warnx("Bad IP address to listen on.\n");
usage(); usage();