1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-26 15:06:04 +03:00

rewrote handshake to include server ip

This commit is contained in:
Bjorn Andersson 2006-08-24 21:23:29 +00:00
parent 0289db7b36
commit a8a63a1258
2 changed files with 44 additions and 39 deletions

View File

@ -110,15 +110,16 @@ tunnel(int tun_fd, int dns_fd)
static int
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 r;
char *p;
int mtu;
int read;
fd_set fds;
int timeout;
char in[4096];
struct timeval tv;
timeout = 1;
@ -142,12 +143,10 @@ handshake(int dns_fd)
}
if (read > 0) {
p = strchr(in, '-');
if (p) {
*p++ = '\0';
mtu = atoi(p);
if (sscanf(in, "%[^-]-%[^-]-%d", server, client, &mtu) == 3) {
printf("%s %s %d\n", server, client, mtu);
if (tun_setip(in) == 0 && tun_setmtu(atoi(p)) == 0)
if (tun_setip(client) == 0 && tun_setmtu(mtu) == 0)
return 0;
else
warn("Received handshake but b0rk");
@ -161,10 +160,10 @@ handshake(int dns_fd)
return 1;
}
extern char *__progname;
static void
usage() {
extern char *__progname;
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] "
"nameserver topdomain\n", __progname);
exit(2);
@ -172,6 +171,8 @@ usage() {
static void
help() {
extern char *__progname;
printf("iodine IP over DNS tunneling client\n");
printf("Usage: %s [-v] [-h] [-f] [-u user] [-t chrootdir] [-d device] "
"nameserver topdomain\n", __progname);
@ -197,17 +198,17 @@ version() {
int
main(int argc, char **argv)
{
int choice;
char *newroot;
char *username;
char *device;
int foreground;
struct passwd *pw;
char *username;
int foreground;
char *newroot;
char *device;
int choice;
newroot = NULL;
username = NULL;
device = NULL;
foreground = 0;
newroot = NULL;
device = NULL;
while ((choice = getopt(argc, argv, "vfhu:t:d:")) != -1) {
switch(choice) {

View File

@ -58,16 +58,17 @@ sigint(int sig) {
static int
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 code;
int ipadder;
struct in_addr nextip;
fd_set fds;
struct timeval tv;
char in[64*1024];
long outlen;
char out[64*1024];
int i;
while (running) {
if (q.id != 0) {
@ -114,17 +115,20 @@ tunnel(int tun_fd, int dns_fd)
continue;
if(in[0] == 'H' || in[0] == 'h') {
ipadder = htonl(my_ip); // To get the last byte last
if ((ipadder & 0xFF) == 0xFF) {
// IP ends with 255.
ipadder--;
} else {
ipadder++;
}
nextip.s_addr = ntohl(ipadder);
read = snprintf(out, sizeof(out), "%s-%d", inet_ntoa(nextip), my_mtu);
myip.s_addr = my_ip;
clientip.s_addr = my_ip + inet_addr("0.0.0.1");
tmp[0] = strdup(inet_ntoa(myip));
tmp[1] = strdup(inet_ntoa(clientip));
read = snprintf(out, sizeof(out), "%s-%s-%d",
tmp[0], tmp[1], my_mtu);
dnsd_send(dns_fd, &q, out, read);
q.id = 0;
free(tmp[1]);
free(tmp[0]);
} else if((in[0] >= '0' && in[0] <= '9')
|| (in[0] >= 'a' && in[0] <= 'f')
|| (in[0] >= 'A' && in[0] <= 'F')) {