From 36b134361b10f775d5fc1d22ff7c5b7267c7ff2f Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 5 Jun 2006 23:49:18 +0000 Subject: [PATCH] server sends data in response --- dns.c | 2 +- dnsd.c | 11 ++++++++--- dnstun.c | 7 +------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dns.c b/dns.c index 98537a3..53545ac 100644 --- a/dns.c +++ b/dns.c @@ -185,7 +185,7 @@ dns_ping(int dns_fd) printf("No reply on chunk, resending\n"); dns_send_chunk(dns_fd); } else { - dns_write(dns_fd, dns_fd, "", 1); + dns_write(dns_fd, dns_fd, "", 0); } } diff --git a/dnsd.c b/dnsd.c index 0b40fc9..21d51fd 100644 --- a/dnsd.c +++ b/dnsd.c @@ -198,22 +198,27 @@ dnsd_respond(int fd, short id, struct sockaddr_in from) header->rd = 0; header->ra = 0; - header->ancount = htons(1); + if(outbuflen > 0) + header->ancount = htons(1); + else + header->ancount = htons(0); p = buf + sizeof(HEADER); p += host2dns("fluff", p, 5); - PUTSHORT(T_PTR, p); + PUTSHORT(T_NULL, p); PUTSHORT(C_IN, p); PUTLONG(htons(3600), p); - size = host2dns("mupp", p+2, 4); + size = host2dns(outbuf, p+2, outbuflen); PUTSHORT(size, p); p += size; len = p - buf; printf("%d\n", len); sendto(fd, buf, len, 0, (struct sockaddr*)&from, sizeof(from)); + + outbuflen = 0; } int diff --git a/dnstun.c b/dnstun.c index 289dac0..ea310a9 100644 --- a/dnstun.c +++ b/dnstun.c @@ -70,16 +70,11 @@ tunnel(int tun_fd, int dns_fd) } if(i == 0) { - //dns_ping(dns_fd); + dns_ping(dns_fd); } else { if(FD_ISSET(tun_fd, &fds)) { read = read_tun(tun_fd, frame, FRAMESIZE); if (read > 0) { - int fd; - - fd = open("moo", O_WRONLY | O_CREAT, S_IRGRP); - write(fd, frame->data, read - 4); - close(fd); printf("Got data on tun! %d bytes\n", read); dns_handle_tun(dns_fd, frame->data, read - 4); }