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 */
|
if(header->qr) { /* qr=1 => response */
|
||||||
ancount = ntohs(header->ancount);
|
ancount = ntohs(header->ancount);
|
||||||
|
|
||||||
|
rlen = 0;
|
||||||
|
|
||||||
for(i=0;i<ancount;i++) {
|
for(i=0;i<ancount;i++) {
|
||||||
READNAME(packet, name, data);
|
READNAME(packet, name, data);
|
||||||
READSHORT(type, data);
|
READSHORT(type, data);
|
||||||
|
@ -325,17 +327,8 @@ dns_read(int fd, char *buf, int buflen)
|
||||||
READSHORT(rlen, data);
|
READSHORT(rlen, data);
|
||||||
READDATA(rdata, data, rlen);
|
READDATA(rdata, data, rlen);
|
||||||
|
|
||||||
if(type == T_SRV && rlen > 6) {
|
if(type == T_NULL) {
|
||||||
char *r;
|
memcpy(buf, rdata, rlen);
|
||||||
short priority;
|
|
||||||
short weight;
|
|
||||||
|
|
||||||
r = rdata;
|
|
||||||
|
|
||||||
READSHORT(priority, r);
|
|
||||||
READSHORT(weight, r);
|
|
||||||
READSHORT(port, r);
|
|
||||||
READNAME(packet, host, r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dns_sending() && chunkid == ntohs(header->id)) {
|
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
|
// 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)
|
dnsd_respond(int fd, short id, struct sockaddr_in from)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int size;
|
|
||||||
HEADER *header;
|
|
||||||
char *p;
|
char *p;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
HEADER *header;
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
|
|
9
dnstun.c
9
dnstun.c
|
@ -24,12 +24,11 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "tun.h"
|
#include "tun.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
|
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
|
||||||
|
|
||||||
#define FRAMESIZE (64*1024)
|
#define FRAMESIZE (64*1024)
|
||||||
|
|
||||||
int running = 1;
|
int running = 1;
|
||||||
|
@ -75,6 +74,7 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
if(FD_ISSET(tun_fd, &fds)) {
|
if(FD_ISSET(tun_fd, &fds)) {
|
||||||
read = read_tun(tun_fd, frame, FRAMESIZE);
|
read = read_tun(tun_fd, frame, FRAMESIZE);
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
|
printf("%04x\n", frame->proto);
|
||||||
printf("Got data on tun! %d bytes\n", read);
|
printf("Got data on tun! %d bytes\n", read);
|
||||||
dns_handle_tun(dns_fd, frame->data, read - 4);
|
dns_handle_tun(dns_fd, frame->data, read - 4);
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,9 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
printf("Got data on dns! %d bytes\n", read);
|
printf("Got data on dns! %d bytes\n", read);
|
||||||
|
|
||||||
frame->flags = htons(0x0000);
|
//frame->flags = htons(0x0000);
|
||||||
frame->proto = htons(0x0800);
|
//frame->proto = htons(0x0200);
|
||||||
|
|
||||||
write_tun(tun_fd, frame, read + 4);
|
write_tun(tun_fd, frame, read + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,14 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "tun.h"
|
#include "tun.h"
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "dnsd.h"
|
#include "dnsd.h"
|
||||||
|
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
|
||||||
|
|
||||||
int running = 1;
|
int running = 1;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sigint(int sig) {
|
sigint(int sig) {
|
||||||
running = 0;
|
running = 0;
|
||||||
|
|
Loading…
Reference in a new issue