mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 14:41:28 +00:00
signal fluff for qujitting
This commit is contained in:
parent
5c61baa2be
commit
e1c0a595df
15
dnstun.c
15
dnstun.c
|
@ -17,6 +17,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
#include "tun.h"
|
#include "tun.h"
|
||||||
|
@ -24,6 +25,13 @@
|
||||||
|
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
|
int running = 1;
|
||||||
|
|
||||||
|
static void
|
||||||
|
sigint(int sig) {
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
tunnel(int tun_fd, int dns_fd)
|
tunnel(int tun_fd, int dns_fd)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +39,7 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
for (;;) {
|
while (running) {
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
@ -69,11 +77,16 @@ main()
|
||||||
|
|
||||||
tun_fd = open_tun();
|
tun_fd = open_tun();
|
||||||
dns_fd = open_dns();
|
dns_fd = open_dns();
|
||||||
|
|
||||||
|
signal(SIGINT, sigint);
|
||||||
|
|
||||||
dns_set_peer("192.168.11.101");
|
dns_set_peer("192.168.11.101");
|
||||||
dns_query(dns_fd, "kryo.se", 1);
|
dns_query(dns_fd, "kryo.se", 1);
|
||||||
|
|
||||||
tunnel(tun_fd, dns_fd);
|
tunnel(tun_fd, dns_fd);
|
||||||
|
|
||||||
|
printf("Closing tunnel\n");
|
||||||
|
|
||||||
close_dns(dns_fd);
|
close_dns(dns_fd);
|
||||||
close_tun(tun_fd);
|
close_tun(tun_fd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue