mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-25 15:41:26 +00:00
we got pong
This commit is contained in:
parent
f26723ff2c
commit
08643a6641
17
dns.c
17
dns.c
|
@ -317,6 +317,8 @@ dns_read(int fd, char *buf, int buflen)
|
|||
if(header->qr) { /* qr=1 => response */
|
||||
ancount = ntohs(header->ancount);
|
||||
|
||||
rlen = 0;
|
||||
|
||||
for(i=0;i<ancount;i++) {
|
||||
READNAME(packet, name, data);
|
||||
READSHORT(type, data);
|
||||
|
@ -325,17 +327,8 @@ dns_read(int fd, char *buf, int buflen)
|
|||
READSHORT(rlen, data);
|
||||
READDATA(rdata, data, rlen);
|
||||
|
||||
if(type == T_SRV && rlen > 6) {
|
||||
char *r;
|
||||
short priority;
|
||||
short weight;
|
||||
|
||||
r = rdata;
|
||||
|
||||
READSHORT(priority, r);
|
||||
READSHORT(weight, r);
|
||||
READSHORT(port, r);
|
||||
READNAME(packet, host, r);
|
||||
if(type == T_NULL) {
|
||||
memcpy(buf, rdata, rlen);
|
||||
}
|
||||
}
|
||||
if (dns_sending() && chunkid == ntohs(header->id)) {
|
||||
|
@ -354,7 +347,7 @@ dns_read(int fd, char *buf, int buflen)
|
|||
}
|
||||
|
||||
// TODO is any data attached? find out and copy into buf and return length
|
||||
return 0;
|
||||
return rlen;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
3
dnsd.c
3
dnsd.c
|
@ -180,10 +180,9 @@ static void
|
|||
dnsd_respond(int fd, short id, struct sockaddr_in from)
|
||||
{
|
||||
int len;
|
||||
int size;
|
||||
HEADER *header;
|
||||
char *p;
|
||||
char buf[1024];
|
||||
HEADER *header;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
|
|
9
dnstun.c
9
dnstun.c
|
@ -24,12 +24,11 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "tun.h"
|
||||
#include "dns.h"
|
||||
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
#define FRAMESIZE (64*1024)
|
||||
|
||||
int running = 1;
|
||||
|
@ -75,6 +74,7 @@ tunnel(int tun_fd, int dns_fd)
|
|||
if(FD_ISSET(tun_fd, &fds)) {
|
||||
read = read_tun(tun_fd, frame, FRAMESIZE);
|
||||
if (read > 0) {
|
||||
printf("%04x\n", frame->proto);
|
||||
printf("Got data on tun! %d bytes\n", read);
|
||||
dns_handle_tun(dns_fd, frame->data, read - 4);
|
||||
}
|
||||
|
@ -84,8 +84,9 @@ tunnel(int tun_fd, int dns_fd)
|
|||
if (read > 0) {
|
||||
printf("Got data on dns! %d bytes\n", read);
|
||||
|
||||
frame->flags = htons(0x0000);
|
||||
frame->proto = htons(0x0800);
|
||||
//frame->flags = htons(0x0000);
|
||||
//frame->proto = htons(0x0200);
|
||||
|
||||
write_tun(tun_fd, frame, read + 4);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue