diff --git a/dns.c b/dns.c index 4a6bc93..1b381d1 100644 --- a/dns.c +++ b/dns.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,8 @@ #include "dns.h" +struct sockaddr_in peer; + int open_dns() { @@ -68,3 +71,15 @@ close_dns(int fd) { close(fd); } + +void +dns_set_peer(const char *host) +{ + struct hostent *h; + + h = gethostbyname(host); + bzero(&peer, sizeof(peer)); + peer.sin_family = AF_INET; + peer.sin_port = htons(53); + peer.sin_addr = *((struct in_addr *) h->h_addr); +} diff --git a/dns.h b/dns.h index b26b9fb..647febe 100644 --- a/dns.h +++ b/dns.h @@ -19,7 +19,11 @@ #ifndef _DNS_H_ #define _DNS_H_ +extern struct sockaddr_in peer; + int open_dns(); void close_dns(int); +void dns_set_peer(const char *); + #endif /* _DNS_H_ */ diff --git a/dnstun.c b/dnstun.c index ea66cc3..90d9933 100644 --- a/dnstun.c +++ b/dnstun.c @@ -29,7 +29,7 @@ main() open_tun(); dnssock = open_dns(); - + dns_set_peer("192.168.11.101"); close_dns(dnssock); close_tun();