mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 14:41:28 +00:00
rewrote handshake to include server ip
This commit is contained in:
parent
0289db7b36
commit
a8a63a1258
43
iodine.c
43
iodine.c
|
@ -110,15 +110,16 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
static int
|
static int
|
||||||
handshake(int dns_fd)
|
handshake(int dns_fd)
|
||||||
{
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
char server[128];
|
||||||
|
char client[128];
|
||||||
|
char in[4096];
|
||||||
|
int timeout;
|
||||||
|
fd_set fds;
|
||||||
|
int read;
|
||||||
|
int mtu;
|
||||||
int i;
|
int i;
|
||||||
int r;
|
int r;
|
||||||
char *p;
|
|
||||||
int mtu;
|
|
||||||
int read;
|
|
||||||
fd_set fds;
|
|
||||||
int timeout;
|
|
||||||
char in[4096];
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
timeout = 1;
|
timeout = 1;
|
||||||
|
|
||||||
|
@ -142,12 +143,10 @@ handshake(int dns_fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
p = strchr(in, '-');
|
if (sscanf(in, "%[^-]-%[^-]-%d", server, client, &mtu) == 3) {
|
||||||
if (p) {
|
printf("%s %s %d\n", server, client, mtu);
|
||||||
*p++ = '\0';
|
|
||||||
mtu = atoi(p);
|
|
||||||
|
|
||||||
if (tun_setip(in) == 0 && tun_setmtu(atoi(p)) == 0)
|
if (tun_setip(client) == 0 && tun_setmtu(mtu) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
warn("Received handshake but b0rk");
|
warn("Received handshake but b0rk");
|
||||||
|
@ -161,10 +160,10 @@ handshake(int dns_fd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage() {
|
usage() {
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] "
|
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,6 +171,8 @@ usage() {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help() {
|
help() {
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
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] [-d device] "
|
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] "
|
||||||
"nameserver topdomain\n", __progname);
|
"nameserver topdomain\n", __progname);
|
||||||
|
@ -197,17 +198,17 @@ version() {
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int choice;
|
|
||||||
char *newroot;
|
|
||||||
char *username;
|
|
||||||
char *device;
|
|
||||||
int foreground;
|
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
char *username;
|
||||||
|
int foreground;
|
||||||
|
char *newroot;
|
||||||
|
char *device;
|
||||||
|
int choice;
|
||||||
|
|
||||||
newroot = NULL;
|
|
||||||
username = NULL;
|
username = NULL;
|
||||||
device = NULL;
|
|
||||||
foreground = 0;
|
foreground = 0;
|
||||||
|
newroot = NULL;
|
||||||
|
device = NULL;
|
||||||
|
|
||||||
while ((choice = getopt(argc, argv, "vfhu:t:d:")) != -1) {
|
while ((choice = getopt(argc, argv, "vfhu:t:d:")) != -1) {
|
||||||
switch(choice) {
|
switch(choice) {
|
||||||
|
|
40
iodined.c
40
iodined.c
|
@ -58,17 +58,18 @@ sigint(int sig) {
|
||||||
static int
|
static int
|
||||||
tunnel(int tun_fd, int dns_fd)
|
tunnel(int tun_fd, int dns_fd)
|
||||||
{
|
{
|
||||||
int i;
|
struct in_addr clientip;
|
||||||
|
struct in_addr myip;
|
||||||
|
struct timeval tv;
|
||||||
|
char out[64*1024];
|
||||||
|
char in[64*1024];
|
||||||
|
char *tmp[2];
|
||||||
|
long outlen;
|
||||||
|
fd_set fds;
|
||||||
int read;
|
int read;
|
||||||
int code;
|
int code;
|
||||||
int ipadder;
|
int i;
|
||||||
struct in_addr nextip;
|
|
||||||
fd_set fds;
|
|
||||||
struct timeval tv;
|
|
||||||
char in[64*1024];
|
|
||||||
long outlen;
|
|
||||||
char out[64*1024];
|
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
if (q.id != 0) {
|
if (q.id != 0) {
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
|
@ -114,17 +115,20 @@ tunnel(int tun_fd, int dns_fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(in[0] == 'H' || in[0] == 'h') {
|
if(in[0] == 'H' || in[0] == 'h') {
|
||||||
ipadder = htonl(my_ip); // To get the last byte last
|
myip.s_addr = my_ip;
|
||||||
if ((ipadder & 0xFF) == 0xFF) {
|
clientip.s_addr = my_ip + inet_addr("0.0.0.1");
|
||||||
// IP ends with 255.
|
|
||||||
ipadder--;
|
tmp[0] = strdup(inet_ntoa(myip));
|
||||||
} else {
|
tmp[1] = strdup(inet_ntoa(clientip));
|
||||||
ipadder++;
|
|
||||||
}
|
read = snprintf(out, sizeof(out), "%s-%s-%d",
|
||||||
nextip.s_addr = ntohl(ipadder);
|
tmp[0], tmp[1], my_mtu);
|
||||||
read = snprintf(out, sizeof(out), "%s-%d", inet_ntoa(nextip), my_mtu);
|
|
||||||
dnsd_send(dns_fd, &q, out, read);
|
dnsd_send(dns_fd, &q, out, read);
|
||||||
q.id = 0;
|
q.id = 0;
|
||||||
|
|
||||||
|
free(tmp[1]);
|
||||||
|
free(tmp[0]);
|
||||||
} else if((in[0] >= '0' && in[0] <= '9')
|
} else if((in[0] >= '0' && in[0] <= '9')
|
||||||
|| (in[0] >= 'a' && in[0] <= 'f')
|
|| (in[0] >= 'a' && in[0] <= 'f')
|
||||||
|| (in[0] >= 'A' && in[0] <= 'F')) {
|
|| (in[0] >= 'A' && in[0] <= 'F')) {
|
||||||
|
|
Loading…
Reference in a new issue