2006-06-05 15:41:08 +03:00
|
|
|
/*
|
2009-01-04 01:27:21 +02:00
|
|
|
* Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
|
2006-06-05 15:41:08 +03:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-06-05 15:48:30 +03:00
|
|
|
#include <stdint.h>
|
2006-06-05 20:22:35 +03:00
|
|
|
#include <stdlib.h>
|
2006-06-05 17:43:04 +03:00
|
|
|
#include <string.h>
|
2006-06-05 17:46:10 +03:00
|
|
|
#include <signal.h>
|
2006-06-05 18:13:30 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
2008-07-12 15:26:41 +03:00
|
|
|
#include <sys/param.h>
|
2007-06-17 14:46:05 +03:00
|
|
|
#include <sys/time.h>
|
2006-06-06 02:34:23 +03:00
|
|
|
#include <fcntl.h>
|
2009-07-23 10:03:09 +03:00
|
|
|
#include <time.h>
|
2009-01-25 00:19:11 +02:00
|
|
|
|
|
|
|
#ifdef WINDOWS32
|
|
|
|
#include "windows.h"
|
2009-03-07 02:00:58 +02:00
|
|
|
#include <winsock2.h>
|
2009-01-25 00:19:11 +02:00
|
|
|
#else
|
|
|
|
#include <grp.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
2006-06-05 15:41:08 +03:00
|
|
|
|
2007-02-04 17:21:55 +02:00
|
|
|
#include "common.h"
|
|
|
|
#include "tun.h"
|
2009-08-16 15:30:26 +03:00
|
|
|
#include "client.h"
|
|
|
|
#include "util.h"
|
2006-06-05 15:41:08 +03:00
|
|
|
|
2009-01-25 19:13:12 +02:00
|
|
|
#ifdef WINDOWS32
|
2009-02-21 12:07:10 +02:00
|
|
|
WORD req_version = MAKEWORD(2, 2);
|
2009-01-25 19:13:12 +02:00
|
|
|
WSADATA wsa_data;
|
|
|
|
#endif
|
|
|
|
|
2008-07-12 15:26:41 +03:00
|
|
|
#if !defined(BSD) && !defined(__GLIBC__)
|
|
|
|
static char *__progname;
|
|
|
|
#endif
|
|
|
|
|
2009-09-19 11:09:12 +03:00
|
|
|
#define PASSWORD_ENV_VAR "IODINE_PASS"
|
|
|
|
|
2006-06-05 17:46:10 +03:00
|
|
|
static void
|
2007-02-04 19:00:20 +02:00
|
|
|
sighandler(int sig)
|
|
|
|
{
|
2009-08-16 15:30:26 +03:00
|
|
|
client_stop();
|
2007-02-04 22:37:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 23:35:26 +03:00
|
|
|
static void
|
|
|
|
usage() {
|
2006-08-25 00:23:29 +03:00
|
|
|
extern char *__progname;
|
|
|
|
|
2009-08-16 01:02:00 +03:00
|
|
|
fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] "
|
2009-09-21 00:10:44 +03:00
|
|
|
"[-P password] [-m maxfragsize] [-T type] [-O enc] [-L 0|1] [-I sec] "
|
|
|
|
"[-z context] [-F pidfile] [nameserver] topdomain\n", __progname);
|
2006-06-09 23:35:26 +03:00
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2006-06-11 16:14:57 +03:00
|
|
|
static void
|
|
|
|
help() {
|
2006-08-25 00:23:29 +03:00
|
|
|
extern char *__progname;
|
|
|
|
|
2009-02-28 16:35:03 +02:00
|
|
|
fprintf(stderr, "iodine IP over DNS tunneling client\n");
|
2009-08-16 01:02:00 +03:00
|
|
|
fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] "
|
2009-09-21 00:10:44 +03:00
|
|
|
"[-P password] [-m maxfragsize] [-T type] [-O enc] [-L 0|1] [-I sec] "
|
|
|
|
"[-z context] [-F pidfile] [nameserver] topdomain\n", __progname);
|
2009-02-28 16:35:03 +02:00
|
|
|
fprintf(stderr, " -v to print version info and exit\n");
|
|
|
|
fprintf(stderr, " -h to print this help and exit\n");
|
|
|
|
fprintf(stderr, " -f to keep running in foreground\n");
|
2009-08-16 01:02:00 +03:00
|
|
|
fprintf(stderr, " -r to skip raw UDP mode attempt\n");
|
2009-02-28 16:35:03 +02:00
|
|
|
fprintf(stderr, " -u name to drop privileges and run as user 'name'\n");
|
|
|
|
fprintf(stderr, " -t dir to chroot to directory dir\n");
|
|
|
|
fprintf(stderr, " -d device to set tunnel device name\n");
|
|
|
|
fprintf(stderr, " -P password used for authentication (max 32 chars will be used)\n");
|
|
|
|
fprintf(stderr, " -m maxfragsize, to limit size of downstream packets\n");
|
2009-09-20 18:11:15 +03:00
|
|
|
fprintf(stderr, " -T dns type: NULL (default, fastest), TXT, CNAME, A (CNAME answer), MX\n");
|
|
|
|
fprintf(stderr, " -O downstream encoding (!NULL): Base32(default), Base64, or Raw (only TXT)\n");
|
2009-09-21 00:10:44 +03:00
|
|
|
fprintf(stderr, " -L 1: try lazy mode for low-latency (default). 0: don't (implies -I1)\n");
|
|
|
|
fprintf(stderr, " -I max interval between requests (default 4 sec) to prevent server timeouts\n");
|
2009-06-24 20:28:13 +03:00
|
|
|
fprintf(stderr, " -z context, to apply specified SELinux context after initialization\n");
|
2009-08-16 00:52:49 +03:00
|
|
|
fprintf(stderr, " -F pidfile to write pid to a file\n");
|
2009-09-26 12:42:32 +03:00
|
|
|
fprintf(stderr, "nameserver is the IP number/hostname of the relaying nameserver. if absent, /etc/resolv.conf is used\n");
|
2009-02-28 16:35:03 +02:00
|
|
|
fprintf(stderr, "topdomain is the FQDN that is delegated to the tunnel endpoint.\n");
|
2007-02-06 18:01:09 +02:00
|
|
|
|
2006-06-11 16:14:57 +03:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2006-06-11 16:27:48 +03:00
|
|
|
static void
|
|
|
|
version() {
|
2007-02-06 18:01:09 +02:00
|
|
|
char *svnver;
|
2008-07-12 14:36:39 +03:00
|
|
|
|
2007-02-06 18:01:09 +02:00
|
|
|
svnver = "$Rev$ from $Date$";
|
|
|
|
|
2009-02-28 16:35:03 +02:00
|
|
|
fprintf(stderr, "iodine IP over DNS tunneling client\n");
|
|
|
|
fprintf(stderr, "SVN version: %s\n", svnver);
|
2007-02-06 18:01:09 +02:00
|
|
|
|
2006-06-11 16:27:48 +03:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2006-06-05 15:41:08 +03:00
|
|
|
int
|
2006-06-05 20:22:35 +03:00
|
|
|
main(int argc, char **argv)
|
2006-06-05 15:41:08 +03:00
|
|
|
{
|
2007-07-12 16:01:18 +03:00
|
|
|
char *nameserv_addr;
|
2009-08-16 15:30:26 +03:00
|
|
|
char *topdomain;
|
2009-01-25 00:19:11 +02:00
|
|
|
#ifndef WINDOWS32
|
2006-08-25 00:23:29 +03:00
|
|
|
struct passwd *pw;
|
2009-01-25 00:19:11 +02:00
|
|
|
#endif
|
2006-06-09 23:35:26 +03:00
|
|
|
char *username;
|
2009-08-16 15:30:26 +03:00
|
|
|
char password[33];
|
2006-06-11 16:05:41 +03:00
|
|
|
int foreground;
|
2006-08-25 00:23:29 +03:00
|
|
|
char *newroot;
|
2009-06-24 20:28:13 +03:00
|
|
|
char *context;
|
2006-08-25 00:23:29 +03:00
|
|
|
char *device;
|
2009-08-16 00:52:49 +03:00
|
|
|
char *pidfile;
|
2006-08-25 00:23:29 +03:00
|
|
|
int choice;
|
2006-08-25 01:12:45 +03:00
|
|
|
int tun_fd;
|
|
|
|
int dns_fd;
|
2009-02-15 23:12:47 +02:00
|
|
|
int max_downstream_frag_size;
|
|
|
|
int autodetect_frag_size;
|
2009-06-24 19:29:30 +03:00
|
|
|
int retval;
|
2009-08-15 13:45:07 +03:00
|
|
|
int raw_mode;
|
2009-09-21 00:10:44 +03:00
|
|
|
int lazymode;
|
|
|
|
int selecttimeout;
|
2006-06-09 23:35:26 +03:00
|
|
|
|
2009-08-15 22:28:48 +03:00
|
|
|
nameserv_addr = NULL;
|
2009-08-16 15:30:26 +03:00
|
|
|
topdomain = NULL;
|
2009-08-15 22:35:07 +03:00
|
|
|
#ifndef WINDOWS32
|
2009-08-15 22:28:48 +03:00
|
|
|
pw = NULL;
|
2009-08-15 22:35:07 +03:00
|
|
|
#endif
|
2007-02-06 18:01:09 +02:00
|
|
|
username = NULL;
|
2009-08-16 15:33:28 +03:00
|
|
|
memset(password, 0, 33);
|
2009-09-20 18:11:15 +03:00
|
|
|
srand(time(NULL));
|
2006-06-11 16:05:41 +03:00
|
|
|
foreground = 0;
|
2006-08-25 00:23:29 +03:00
|
|
|
newroot = NULL;
|
2009-06-24 20:28:13 +03:00
|
|
|
context = NULL;
|
2006-08-25 00:23:29 +03:00
|
|
|
device = NULL;
|
2009-08-16 00:52:49 +03:00
|
|
|
pidfile = NULL;
|
2007-06-09 19:18:59 +03:00
|
|
|
|
2009-01-05 21:47:59 +02:00
|
|
|
autodetect_frag_size = 1;
|
|
|
|
max_downstream_frag_size = 3072;
|
2009-06-24 19:29:30 +03:00
|
|
|
retval = 0;
|
2009-08-16 15:30:26 +03:00
|
|
|
raw_mode = 1;
|
2009-09-21 00:10:44 +03:00
|
|
|
lazymode = 1;
|
|
|
|
selecttimeout = 4;
|
2009-06-24 19:29:30 +03:00
|
|
|
|
2009-01-25 19:13:12 +02:00
|
|
|
#ifdef WINDOWS32
|
|
|
|
WSAStartup(req_version, &wsa_data);
|
|
|
|
#endif
|
2009-07-23 10:03:09 +03:00
|
|
|
|
|
|
|
srand((unsigned) time(NULL));
|
2009-08-16 15:30:26 +03:00
|
|
|
client_init();
|
2006-06-11 15:45:46 +03:00
|
|
|
|
2008-07-12 15:26:41 +03:00
|
|
|
#if !defined(BSD) && !defined(__GLIBC__)
|
|
|
|
__progname = strrchr(argv[0], '/');
|
|
|
|
if (__progname == NULL)
|
|
|
|
__progname = argv[0];
|
|
|
|
else
|
|
|
|
__progname++;
|
|
|
|
#endif
|
|
|
|
|
2009-09-21 00:10:44 +03:00
|
|
|
while ((choice = getopt(argc, argv, "vfhru:t:d:P:m:F:T:O:L:I:")) != -1) {
|
2006-06-09 23:35:26 +03:00
|
|
|
switch(choice) {
|
2006-06-11 16:27:48 +03:00
|
|
|
case 'v':
|
|
|
|
version();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2006-06-11 16:27:48 +03:00
|
|
|
break;
|
2006-06-11 16:05:41 +03:00
|
|
|
case 'f':
|
|
|
|
foreground = 1;
|
|
|
|
break;
|
2006-06-11 16:14:57 +03:00
|
|
|
case 'h':
|
|
|
|
help();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2006-06-11 16:14:57 +03:00
|
|
|
break;
|
2009-08-15 13:45:07 +03:00
|
|
|
case 'r':
|
|
|
|
raw_mode = 0;
|
2006-06-09 23:35:26 +03:00
|
|
|
case 'u':
|
|
|
|
username = optarg;
|
|
|
|
break;
|
2006-06-11 17:29:36 +03:00
|
|
|
case 't':
|
|
|
|
newroot = optarg;
|
|
|
|
break;
|
2006-06-24 13:28:24 +03:00
|
|
|
case 'd':
|
|
|
|
device = optarg;
|
|
|
|
break;
|
2006-11-18 18:08:47 +02:00
|
|
|
case 'P':
|
2007-08-26 18:47:32 +03:00
|
|
|
strncpy(password, optarg, sizeof(password));
|
|
|
|
password[sizeof(password)-1] = 0;
|
2007-07-12 16:36:24 +03:00
|
|
|
|
|
|
|
/* XXX: find better way of cleaning up ps(1) */
|
|
|
|
memset(optarg, 0, strlen(optarg));
|
2006-11-18 18:08:47 +02:00
|
|
|
break;
|
2009-01-05 21:47:59 +02:00
|
|
|
case 'm':
|
|
|
|
autodetect_frag_size = 0;
|
|
|
|
max_downstream_frag_size = atoi(optarg);
|
|
|
|
break;
|
2009-06-24 20:28:13 +03:00
|
|
|
case 'z':
|
|
|
|
context = optarg;
|
|
|
|
break;
|
2009-08-16 00:52:49 +03:00
|
|
|
case 'F':
|
|
|
|
pidfile = optarg;
|
|
|
|
break;
|
2009-09-20 18:11:15 +03:00
|
|
|
case 'T':
|
|
|
|
set_qtype(optarg);
|
|
|
|
break;
|
|
|
|
case 'O': /* not -D, is Debug in server */
|
|
|
|
set_downenc(optarg);
|
|
|
|
break;
|
2009-09-21 00:10:44 +03:00
|
|
|
case 'L':
|
|
|
|
lazymode = atoi(optarg);
|
|
|
|
if (lazymode > 1)
|
|
|
|
lazymode = 1;
|
|
|
|
if (lazymode < 0)
|
|
|
|
lazymode = 0;
|
|
|
|
if (!lazymode)
|
|
|
|
selecttimeout = 1;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
selecttimeout = atoi(optarg);
|
|
|
|
if (selecttimeout < 1)
|
|
|
|
selecttimeout = 1;
|
|
|
|
break;
|
2006-06-09 23:35:26 +03:00
|
|
|
default:
|
|
|
|
usage();
|
2007-02-04 19:00:20 +02:00
|
|
|
/* NOTREACHED */
|
2006-06-09 23:35:26 +03:00
|
|
|
}
|
|
|
|
}
|
2006-06-11 16:49:36 +03:00
|
|
|
|
2009-01-24 17:50:54 +02:00
|
|
|
check_superuser(usage);
|
2006-06-09 23:35:26 +03:00
|
|
|
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
2007-07-12 16:01:18 +03:00
|
|
|
|
|
|
|
switch (argc) {
|
|
|
|
case 1:
|
|
|
|
nameserv_addr = get_resolvconf_addr();
|
|
|
|
topdomain = strdup(argv[0]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
nameserv_addr = argv[0];
|
|
|
|
topdomain = strdup(argv[1]);
|
|
|
|
break;
|
|
|
|
default:
|
2006-06-09 23:35:26 +03:00
|
|
|
usage();
|
2007-07-12 16:01:18 +03:00
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
2009-01-05 21:47:59 +02:00
|
|
|
if (max_downstream_frag_size < 1 || max_downstream_frag_size > 0xffff) {
|
|
|
|
warnx("Use a max frag size between 1 and 65535 bytes.\n");
|
|
|
|
usage();
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
2009-03-28 19:03:42 +02:00
|
|
|
if (nameserv_addr) {
|
2009-09-20 11:43:48 +03:00
|
|
|
client_set_nameserver(nameserv_addr, DNS_PORT);
|
2009-03-28 19:03:42 +02:00
|
|
|
} else {
|
2009-09-20 18:11:15 +03:00
|
|
|
warnx("No nameserver found - not connected to any network?\n");
|
2009-03-28 19:03:42 +02:00
|
|
|
usage();
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
2007-02-04 22:37:36 +02:00
|
|
|
|
2009-08-06 22:48:54 +03:00
|
|
|
if (strlen(topdomain) <= 128) {
|
2008-07-12 14:41:01 +03:00
|
|
|
if(check_topdomain(topdomain)) {
|
|
|
|
warnx("Topdomain contains invalid characters.\n");
|
|
|
|
usage();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2008-07-12 14:41:01 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
warnx("Use a topdomain max 128 chars long.\n");
|
2007-07-12 02:25:03 +03:00
|
|
|
usage();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2007-07-12 02:25:03 +03:00
|
|
|
}
|
2007-02-04 22:37:36 +02:00
|
|
|
|
2009-09-21 00:10:44 +03:00
|
|
|
client_set_selecttimeout(selecttimeout);
|
|
|
|
client_set_lazymode(lazymode);
|
2009-08-16 15:30:26 +03:00
|
|
|
client_set_topdomain(topdomain);
|
|
|
|
|
2007-07-12 16:36:24 +03:00
|
|
|
if (username != NULL) {
|
2009-01-25 00:19:11 +02:00
|
|
|
#ifndef WINDOWS32
|
2007-07-12 16:36:24 +03:00
|
|
|
if ((pw = getpwnam(username)) == NULL) {
|
|
|
|
warnx("User %s does not exist!\n", username);
|
2006-06-11 15:18:49 +03:00
|
|
|
usage();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2006-06-11 15:18:49 +03:00
|
|
|
}
|
2009-01-25 00:19:11 +02:00
|
|
|
#endif
|
2006-06-11 15:18:49 +03:00
|
|
|
}
|
2006-11-18 18:08:47 +02:00
|
|
|
|
2009-09-19 11:09:12 +03:00
|
|
|
if (strlen(password) == 0) {
|
|
|
|
if (NULL != getenv(PASSWORD_ENV_VAR))
|
|
|
|
snprintf(password, sizeof(password), "%s", getenv(PASSWORD_ENV_VAR));
|
|
|
|
else
|
|
|
|
read_password(password, sizeof(password));
|
|
|
|
}
|
2009-08-16 15:30:26 +03:00
|
|
|
|
|
|
|
client_set_password(password);
|
2006-06-11 15:18:49 +03:00
|
|
|
|
2009-06-24 19:29:30 +03:00
|
|
|
if ((tun_fd = open_tun(device)) == -1) {
|
|
|
|
retval = 1;
|
2006-06-11 20:43:04 +03:00
|
|
|
goto cleanup1;
|
2009-06-24 19:29:30 +03:00
|
|
|
}
|
|
|
|
if ((dns_fd = open_dns(0, INADDR_ANY)) == -1) {
|
|
|
|
retval = 1;
|
2006-06-11 17:42:19 +03:00
|
|
|
goto cleanup2;
|
2009-06-24 19:29:30 +03:00
|
|
|
}
|
2006-06-11 22:54:23 +03:00
|
|
|
|
2006-06-11 21:07:26 +03:00
|
|
|
signal(SIGINT, sighandler);
|
|
|
|
signal(SIGTERM, sighandler);
|
2006-06-11 17:29:36 +03:00
|
|
|
|
2009-08-16 15:30:26 +03:00
|
|
|
if (client_handshake(dns_fd, raw_mode, autodetect_frag_size, max_downstream_frag_size)) {
|
2009-06-24 19:29:30 +03:00
|
|
|
retval = 1;
|
2006-06-11 19:13:40 +03:00
|
|
|
goto cleanup2;
|
2009-06-24 19:29:30 +03:00
|
|
|
}
|
2006-11-18 18:08:47 +02:00
|
|
|
|
2009-08-16 15:30:26 +03:00
|
|
|
if (client_get_conn() == CONN_DNS_NULL) {
|
2009-08-06 22:48:55 +03:00
|
|
|
fprintf(stderr, "Sending queries for %s to %s\n", topdomain, nameserv_addr);
|
|
|
|
} else {
|
2009-08-16 15:30:26 +03:00
|
|
|
fprintf(stderr, "Sending raw traffic directly to %s\n", client_get_raw_addr());
|
2009-08-06 22:48:55 +03:00
|
|
|
}
|
2006-06-11 19:13:40 +03:00
|
|
|
|
2007-11-27 22:11:43 +02:00
|
|
|
if (foreground == 0)
|
|
|
|
do_detach();
|
2009-08-16 00:52:49 +03:00
|
|
|
|
|
|
|
if (pidfile != NULL)
|
|
|
|
do_pidfile(pidfile);
|
2007-11-27 22:11:43 +02:00
|
|
|
|
2007-07-12 16:36:24 +03:00
|
|
|
if (newroot != NULL)
|
|
|
|
do_chroot(newroot);
|
2006-06-05 17:46:10 +03:00
|
|
|
|
2007-07-12 16:36:24 +03:00
|
|
|
if (username != NULL) {
|
2009-01-25 00:19:11 +02:00
|
|
|
#ifndef WINDOWS32
|
2008-07-12 15:05:59 +03:00
|
|
|
gid_t gids[1];
|
|
|
|
gids[0] = pw->pw_gid;
|
|
|
|
if (setgroups(1, gids) < 0 || setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) {
|
2007-07-12 16:36:24 +03:00
|
|
|
warnx("Could not switch to user %s!\n", username);
|
2006-06-09 23:35:26 +03:00
|
|
|
usage();
|
2008-12-11 21:11:53 +02:00
|
|
|
/* NOTREACHED */
|
2006-06-09 23:35:26 +03:00
|
|
|
}
|
2009-01-25 00:19:11 +02:00
|
|
|
#endif
|
2006-06-09 23:35:26 +03:00
|
|
|
}
|
2009-06-24 20:28:13 +03:00
|
|
|
|
|
|
|
if (context != NULL)
|
|
|
|
do_setcon(context);
|
2009-08-16 00:52:49 +03:00
|
|
|
|
2009-08-16 15:30:26 +03:00
|
|
|
client_tunnel(tun_fd, dns_fd);
|
2006-06-05 15:41:08 +03:00
|
|
|
|
2006-06-11 17:42:19 +03:00
|
|
|
cleanup2:
|
2006-06-05 17:43:04 +03:00
|
|
|
close_dns(dns_fd);
|
2006-06-06 14:09:13 +03:00
|
|
|
close_tun(tun_fd);
|
2006-06-11 20:43:04 +03:00
|
|
|
cleanup1:
|
2006-06-05 15:41:08 +03:00
|
|
|
|
2009-06-24 19:29:30 +03:00
|
|
|
return retval;
|
2006-06-05 15:41:08 +03:00
|
|
|
}
|
2009-06-24 19:29:30 +03:00
|
|
|
|