mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-30 13:35:09 +00:00
#36 client now reads raw reply
This commit is contained in:
parent
b37d5481cd
commit
75681834f4
32
src/iodine.c
32
src/iodine.c
@ -678,7 +678,7 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||||||
fd_set fds;
|
fd_set fds;
|
||||||
int i;
|
int i;
|
||||||
int r;
|
int r;
|
||||||
int read;
|
int len;
|
||||||
unsigned remoteaddr = 0;
|
unsigned remoteaddr = 0;
|
||||||
struct in_addr server;
|
struct in_addr server;
|
||||||
|
|
||||||
@ -696,8 +696,8 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||||||
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
read = read_dns(dns_fd, in, sizeof(in));
|
len = read_dns(dns_fd, in, sizeof(in));
|
||||||
if (read == 5 && in[0] == 'I') {
|
if (len == 5 && in[0] == 'I') {
|
||||||
/* Received IP address */
|
/* Received IP address */
|
||||||
remoteaddr = (in[1] & 0xff);
|
remoteaddr = (in[1] & 0xff);
|
||||||
remoteaddr <<= 8;
|
remoteaddr <<= 8;
|
||||||
@ -719,7 +719,7 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||||||
fprintf(stderr, " failed to get IP.\n");
|
fprintf(stderr, " failed to get IP.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fprintf(stderr, " at %s", inet_ntoa(server));
|
fprintf(stderr, " at %s: ", inet_ntoa(server));
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
/* Store address to iodined server */
|
/* Store address to iodined server */
|
||||||
@ -743,18 +743,26 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||||||
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
read = read_dns(dns_fd, in, sizeof(in));
|
len = read(dns_fd, in, sizeof(in));
|
||||||
} else {
|
if (len >= (17 + RAW_HDR_LEN)) {
|
||||||
fprintf(stderr, ".");
|
char hash[16];
|
||||||
fflush(stderr);
|
login_calculate(hash, 16, password, seed - 1);
|
||||||
|
if (memcmp(in, raw_header, RAW_HDR_IDENT_LEN) == 0
|
||||||
|
&& in[RAW_HDR_CMD] == RAW_HDR_CMD_LOGIN
|
||||||
|
&& memcmp(&in[RAW_HDR_LEN], hash, sizeof(hash)) == 0
|
||||||
|
&& in[16 + RAW_HDR_LEN] == userid) {
|
||||||
|
|
||||||
|
fprintf(stderr, "OK\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, ".");
|
||||||
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "failed\n");
|
||||||
/* TODO */
|
|
||||||
fprintf(stderr, ": not implemented\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
/* TODO and then return 0 on success */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user