mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-23 08:39:20 +02:00
Choose tunnel device name
This commit is contained in:
parent
9a6ad85240
commit
a9d64715c3
14
iodine.c
14
iodine.c
|
@ -164,7 +164,7 @@ extern char *__progname;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage() {
|
usage() {
|
||||||
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] "
|
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device]"
|
||||||
"nameserver topdomain\n", __progname);
|
"nameserver topdomain\n", __progname);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -172,13 +172,14 @@ usage() {
|
||||||
static void
|
static void
|
||||||
help() {
|
help() {
|
||||||
printf("iodine IP over DNS tunneling client\n");
|
printf("iodine IP over DNS tunneling client\n");
|
||||||
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] "
|
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device]"
|
||||||
"nameserver topdomain\n", __progname);
|
"nameserver topdomain\n", __progname);
|
||||||
printf(" -v to print version info and exit\n");
|
printf(" -v to print version info and exit\n");
|
||||||
printf(" -h to print this help and exit\n");
|
printf(" -h to print this help and exit\n");
|
||||||
printf(" -f to keep running in foreground\n");
|
printf(" -f to keep running in foreground\n");
|
||||||
printf(" -u name to drop privileges and run as user 'name'\n");
|
printf(" -u name to drop privileges and run as user 'name'\n");
|
||||||
printf(" -t dir to chroot to directory dir\n");
|
printf(" -t dir to chroot to directory dir\n");
|
||||||
|
printf(" -d device to set tunnel device name\n");
|
||||||
printf("nameserver is the IP number of the relaying nameserver\n");
|
printf("nameserver is the IP number of the relaying nameserver\n");
|
||||||
printf("topdomain is the FQDN that is delegated to the tunnel endpoint.\n");
|
printf("topdomain is the FQDN that is delegated to the tunnel endpoint.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -198,14 +199,16 @@ main(int argc, char **argv)
|
||||||
int choice;
|
int choice;
|
||||||
char *newroot;
|
char *newroot;
|
||||||
char *username;
|
char *username;
|
||||||
|
char *device;
|
||||||
int foreground;
|
int foreground;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
newroot = NULL;
|
newroot = NULL;
|
||||||
username = NULL;
|
username = NULL;
|
||||||
|
device = NULL;
|
||||||
foreground = 0;
|
foreground = 0;
|
||||||
|
|
||||||
while ((choice = getopt(argc, argv, "vfhu:t:")) != -1) {
|
while ((choice = getopt(argc, argv, "vfhu:t:d:")) != -1) {
|
||||||
switch(choice) {
|
switch(choice) {
|
||||||
case 'v':
|
case 'v':
|
||||||
version();
|
version();
|
||||||
|
@ -222,6 +225,9 @@ main(int argc, char **argv)
|
||||||
case 't':
|
case 't':
|
||||||
newroot = optarg;
|
newroot = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
device = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
@ -247,7 +253,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tun_fd = open_tun(NULL)) == -1)
|
if ((tun_fd = open_tun(device)) == -1)
|
||||||
goto cleanup1;
|
goto cleanup1;
|
||||||
if ((dns_fd = open_dns(argv[1], 0)) == -1)
|
if ((dns_fd = open_dns(argv[1], 0)) == -1)
|
||||||
goto cleanup2;
|
goto cleanup2;
|
||||||
|
|
15
iodined.c
15
iodined.c
|
@ -163,7 +163,7 @@ extern char *__progname;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage() {
|
usage() {
|
||||||
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-m mtu] "
|
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] [-m mtu] "
|
||||||
"tunnel_ip topdomain\n", __progname);
|
"tunnel_ip topdomain\n", __progname);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -171,13 +171,15 @@ usage() {
|
||||||
static void
|
static void
|
||||||
help() {
|
help() {
|
||||||
printf("iodine IP over DNS tunneling server\n");
|
printf("iodine IP over DNS tunneling server\n");
|
||||||
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-m mtu] "
|
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] [-m mtu] "
|
||||||
"tunnel_ip topdomain\n", __progname);
|
"tunnel_ip topdomain\n", __progname);
|
||||||
printf(" -v to print version info and exit\n");
|
printf(" -v to print version info and exit\n");
|
||||||
printf(" -h to print this help and exit\n");
|
printf(" -h to print this help and exit\n");
|
||||||
printf(" -f to keep running in foreground\n");
|
printf(" -f to keep running in foreground\n");
|
||||||
printf(" -u name to drop privileges and run as user 'name'\n");
|
printf(" -u name to drop privileges and run as user 'name'\n");
|
||||||
printf(" -t dir to chroot to directory dir\n");
|
printf(" -t dir to chroot to directory dir\n");
|
||||||
|
printf(" -d device to set tunnel device name\n");
|
||||||
|
printf(" -m mtu to set tunnel device mtu\n");
|
||||||
printf("tunnel_ip is the IP number of the local tunnel interface.\n");
|
printf("tunnel_ip is the IP number of the local tunnel interface.\n");
|
||||||
printf("topdomain is the FQDN that is delegated to this server.\n");
|
printf("topdomain is the FQDN that is delegated to this server.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -199,12 +201,14 @@ main(int argc, char **argv)
|
||||||
int dnsd_fd;
|
int dnsd_fd;
|
||||||
char *newroot;
|
char *newroot;
|
||||||
char *username;
|
char *username;
|
||||||
|
char *device;
|
||||||
int foreground;
|
int foreground;
|
||||||
int mtu;
|
int mtu;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
username = NULL;
|
username = NULL;
|
||||||
newroot = NULL;
|
newroot = NULL;
|
||||||
|
device = NULL;
|
||||||
foreground = 0;
|
foreground = 0;
|
||||||
mtu = 1024;
|
mtu = 1024;
|
||||||
|
|
||||||
|
@ -213,7 +217,7 @@ main(int argc, char **argv)
|
||||||
outpacket.len = 0;
|
outpacket.len = 0;
|
||||||
q.id = 0;
|
q.id = 0;
|
||||||
|
|
||||||
while ((choice = getopt(argc, argv, "vfhu:t:m:")) != -1) {
|
while ((choice = getopt(argc, argv, "vfhu:t:d:m:")) != -1) {
|
||||||
switch(choice) {
|
switch(choice) {
|
||||||
case 'v':
|
case 'v':
|
||||||
version();
|
version();
|
||||||
|
@ -230,6 +234,9 @@ main(int argc, char **argv)
|
||||||
case 't':
|
case 't':
|
||||||
newroot = optarg;
|
newroot = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
device = optarg;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
mtu = atoi(optarg);
|
mtu = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -263,7 +270,7 @@ main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tun_fd = open_tun(NULL)) == -1)
|
if ((tun_fd = open_tun(device)) == -1)
|
||||||
goto cleanup0;
|
goto cleanup0;
|
||||||
if (tun_setip(argv[0]) != 0 || tun_setmtu(mtu) != 0)
|
if (tun_setip(argv[0]) != 0 || tun_setmtu(mtu) != 0)
|
||||||
goto cleanup1;
|
goto cleanup1;
|
||||||
|
|
2
tun.c
2
tun.c
|
@ -58,10 +58,10 @@ open_tun(const char *tun_device)
|
||||||
|
|
||||||
if (tun_device != NULL) {
|
if (tun_device != NULL) {
|
||||||
strncpy(ifreq.ifr_name, tun_device, IFNAMSIZ);
|
strncpy(ifreq.ifr_name, tun_device, IFNAMSIZ);
|
||||||
|
strncpy(if_name, tun_device, sizeof(if_name));
|
||||||
|
|
||||||
if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) {
|
if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) {
|
||||||
printf("Opened %s\n", ifreq.ifr_name);
|
printf("Opened %s\n", ifreq.ifr_name);
|
||||||
snprintf(if_name, sizeof(if_name), "dns%d", i);
|
|
||||||
return tun_fd;
|
return tun_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue