Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dig: allow cmdline to spec dns server, default question of root "."
  • Loading branch information
beretta42 committed Jan 17, 2017
1 parent d2a4a3e commit 070a2cc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Applications/netd/dig.c
@@ -1,9 +1,6 @@
/*
A Cheesey Dig Client
todo:
allow setting of dns server :)
*/

#include <stdio.h>
Expand Down Expand Up @@ -36,7 +33,8 @@ struct RRtail{

int fd;
char buf[1024];
char server[17];
char server[17] = "1921.168.1.1";
char name[256] = ".";

void alarm_handler( int signum ){
return;
Expand Down Expand Up @@ -188,6 +186,13 @@ int main( int argc, char *argv[] ){

readrc();

for( x = 1; x < argc; x++ ){
if( argv[x][0] == '@' )
strncpy( server, &(argv[x][1]), 16);
else
strncpy( name, argv[x], 16 );
}

fd = socket( AF_INET, SOCK_DGRAM, 0);
if( fd < 0 ){
perror("socket");
Expand All @@ -204,7 +209,7 @@ int main( int argc, char *argv[] ){
}

for( ; tries ; tries-- ){
send_question( argv[1] );
send_question( name );
signal( SIGALRM, alarm_handler );
alarm(2);
x = read( fd, buf, 1024 );
Expand Down

0 comments on commit 070a2cc

Please sign in to comment.