mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-25 07:31:27 +00:00
cleanup in main
This commit is contained in:
parent
12d79f6e25
commit
7bf9c25ebc
21
dnstun.c
21
dnstun.c
|
@ -116,9 +116,11 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage() {
|
usage() {
|
||||||
printf("Usage: dnstun [-u user] nameserver topdomain\n");
|
printf("Usage: %s [-u user] nameserver topdomain\n", __progname);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,15 +134,11 @@ main(int argc, char **argv)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
username = NULL;
|
username = NULL;
|
||||||
|
|
||||||
while ((choice = getopt(argc, argv, "u:")) != -1) {
|
while ((choice = getopt(argc, argv, "u:")) != -1) {
|
||||||
switch(choice) {
|
switch(choice) {
|
||||||
case 'u':
|
case 'u':
|
||||||
username = optarg;
|
username = optarg;
|
||||||
pw = getpwnam(username);
|
|
||||||
if (!pw) {
|
|
||||||
printf("User %s does not exist!\n", username);
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -150,10 +148,19 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(username) {
|
||||||
|
pw = getpwnam(username);
|
||||||
|
if (!pw) {
|
||||||
|
printf("User %s does not exist!\n", username);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
tun_fd = open_tun();
|
tun_fd = open_tun();
|
||||||
dns_fd = open_dns(argv[0], argv[1]);
|
dns_fd = open_dns(argv[0], argv[1]);
|
||||||
|
|
18
dnstund.c
18
dnstund.c
|
@ -113,9 +113,11 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage() {
|
usage() {
|
||||||
printf("Usage: dnstund [-u user] topdomain\n");
|
printf("Usage: %s [-u user] topdomain\n", __progname);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,15 +131,11 @@ main(int argc, char **argv)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
username = NULL;
|
username = NULL;
|
||||||
|
|
||||||
while ((choice = getopt(argc, argv, "u:")) != -1) {
|
while ((choice = getopt(argc, argv, "u:")) != -1) {
|
||||||
switch(choice) {
|
switch(choice) {
|
||||||
case 'u':
|
case 'u':
|
||||||
username = optarg;
|
username = optarg;
|
||||||
pw = getpwnam(username);
|
|
||||||
if (!pw) {
|
|
||||||
printf("User %s does not exist!\n", username);
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -152,6 +150,14 @@ main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (username) {
|
||||||
|
pw = getpwnam(username);
|
||||||
|
if (!pw) {
|
||||||
|
printf("User %s does not exist!\n", username);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tun_fd = open_tun();
|
tun_fd = open_tun();
|
||||||
dnsd_fd = open_dnsd(argv[0]);
|
dnsd_fd = open_dnsd(argv[0]);
|
||||||
printf("Listening to dns for domain %s\n", argv[0]);
|
printf("Listening to dns for domain %s\n", argv[0]);
|
||||||
|
|
Loading…
Reference in a new issue