#1 move saving of client ip

This commit is contained in:
Erik Ekman 2007-01-31 19:34:27 +00:00
parent 5733c68988
commit 8c7fb4d947
1 changed files with 23 additions and 28 deletions

View File

@ -135,9 +135,6 @@ tunnel(int tun_fd, int dns_fd)
strncpy(out, "VACK", sizeof(out));
memcpy(out+4, &nseed, 4);
dnsd_send(dns_fd, &q, out, 8);
memcpy(&(u.host), &(q.from), q.fromlen);
u.addrlen = q.fromlen;
} else {
version = htonl(VERSION);
strncpy(out, "VNAK", sizeof(out));
@ -151,11 +148,6 @@ tunnel(int tun_fd, int dns_fd)
dnsd_send(dns_fd, &q, out, 8);
}
} else if(in[0] == 'L' || in[0] == 'l') {
// Check sending ip number
if (q.fromlen != u.addrlen ||
memcmp(&(u.host), &(q.from), q.fromlen) != 0) {
dnsd_send(dns_fd, &q, "BADIP", 5);
} else {
// Login phase, handle auth
login_calculate(logindata, 16, password, seed);
if (read >= 17 && (memcmp(logindata, in+1, 16) == 0)) {
@ -169,6 +161,10 @@ tunnel(int tun_fd, int dns_fd)
read = snprintf(out, sizeof(out), "%s-%s-%d",
tmp[0], tmp[1], my_mtu);
// Store user ip
memcpy(&(u.host), &(q.from), q.fromlen);
u.addrlen = q.fromlen;
dnsd_send(dns_fd, &q, out, read);
q.id = 0;
@ -177,7 +173,6 @@ tunnel(int tun_fd, int dns_fd)
} else {
dnsd_send(dns_fd, &q, "LNAK", 4);
}
}
} else if((in[0] >= '0' && in[0] <= '9')
|| (in[0] >= 'a' && in[0] <= 'f')
|| (in[0] >= 'A' && in[0] <= 'F')) {