some cleanup

This commit is contained in:
Bjorn Andersson 2007-07-12 15:18:34 +00:00
parent 0b9a532bbe
commit e5ee739537

View File

@ -163,29 +163,26 @@ tunnel_dns(int tun_fd, int dns_fd)
/* Version greeting, compare and send ack/nak */ /* Version greeting, compare and send ack/nak */
if (read > 4) { if (read > 4) {
/* Received V + 32bits version */ /* Received V + 32bits version */
version = (((unpacked[0] & 0xff) << 24) | version = (((unpacked[0] & 0xff) << 24) |
((unpacked[1] & 0xff) << 16) | ((unpacked[1] & 0xff) << 16) |
((unpacked[2] & 0xff) << 8) | ((unpacked[2] & 0xff) << 8) |
((unpacked[3] & 0xff))); ((unpacked[3] & 0xff)));
}
if (version == VERSION) { if (version == VERSION) {
userid = find_available_user(); userid = find_available_user();
if (userid >= 0) { if (userid >= 0) {
users[userid].seed = rand(); users[userid].seed = rand();
/* Store remote IP number */ /* Store remote IP number */
tempin = (struct sockaddr_in *) &(dummy.q.from); tempin = (struct sockaddr_in *) &(dummy.q.from);
memcpy(&(users[userid].host), &(tempin->sin_addr), sizeof(struct in_addr)); memcpy(&(users[userid].host), &(tempin->sin_addr), sizeof(struct in_addr));
memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query)); memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query));
users[userid].encoder = get_base32_encoder(); users[userid].encoder = get_base32_encoder();
send_version_response(dns_fd, VERSION_ACK, users[userid].seed, &users[userid]); send_version_response(dns_fd, VERSION_ACK, users[userid].seed, &users[userid]);
users[userid].q.id = 0; users[userid].q.id = 0;
} else {
/* No space for another user */
send_version_response(dns_fd, VERSION_FULL, USERS, &dummy);
}
} else { } else {
send_version_response(dns_fd, VERSION_NACK, VERSION, &dummy); /* No space for another user */
send_version_response(dns_fd, VERSION_FULL, USERS, &dummy);
} }
} else { } else {
send_version_response(dns_fd, VERSION_NACK, VERSION, &dummy); send_version_response(dns_fd, VERSION_NACK, VERSION, &dummy);