mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 14:41:28 +00:00
#16 Do case preservation check after login
This commit is contained in:
parent
861da5d022
commit
285a412563
|
@ -12,6 +12,8 @@ CHANGES:
|
||||||
- Refined 'install' make target
|
- Refined 'install' make target
|
||||||
- Fixed bug denying access if relay uses varying source ports
|
- Fixed bug denying access if relay uses varying source ports
|
||||||
- All received error messages (RCODE field) are echoed
|
- All received error messages (RCODE field) are echoed
|
||||||
|
- Top domain limited to 128 chars
|
||||||
|
- Case preservation check sent after login to decide codec
|
||||||
|
|
||||||
2007-03-25: 0.4.0 "Run Home"
|
2007-03-25: 0.4.0 "Run Home"
|
||||||
- Added multiuser support (up to 8 users simultaneously)
|
- Added multiuser support (up to 8 users simultaneously)
|
||||||
|
|
78
src/iodine.c
78
src/iodine.c
|
@ -49,25 +49,33 @@ static int build_hostname(char *buf, size_t buflen,
|
||||||
const char *data, const size_t datalen,
|
const char *data, const size_t datalen,
|
||||||
const char *topdomain, struct encoder *encoder);
|
const char *topdomain, struct encoder *encoder);
|
||||||
|
|
||||||
int running = 1;
|
static int running = 1;
|
||||||
char password[33];
|
static char password[33];
|
||||||
|
|
||||||
struct sockaddr_in peer;
|
static struct sockaddr_in peer;
|
||||||
static char *topdomain;
|
static char *topdomain;
|
||||||
|
|
||||||
uint16_t rand_seed;
|
static uint16_t rand_seed;
|
||||||
|
|
||||||
/* Current IP packet */
|
/* Current IP packet */
|
||||||
static struct packet packet;
|
static struct packet packet;
|
||||||
|
|
||||||
|
/* My userid at the server */
|
||||||
static char userid;
|
static char userid;
|
||||||
|
|
||||||
|
/* DNS id for next packet */
|
||||||
static uint16_t chunkid;
|
static uint16_t chunkid;
|
||||||
|
|
||||||
/* Base32 encoder used for non-data packets */
|
/* Base32 encoder used for non-data packets */
|
||||||
static struct encoder *b32;
|
static struct encoder *b32;
|
||||||
|
|
||||||
/* The encoder used for data packets
|
/* The encoder used for data packets
|
||||||
* Defaults to Base32, can be changed after handshake */
|
* Defaults to Base32, can be changed after handshake */
|
||||||
static struct encoder *dataenc;
|
static struct encoder *dataenc;
|
||||||
|
|
||||||
|
/* result of case preservation check done after login */
|
||||||
|
static int case_preserved;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sighandler(int sig)
|
sighandler(int sig)
|
||||||
{
|
{
|
||||||
|
@ -349,6 +357,15 @@ send_version(int fd, uint32_t version)
|
||||||
send_packet(fd, 'V', data, sizeof(data));
|
send_packet(fd, 'V', data, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
send_case_check(int fd)
|
||||||
|
{
|
||||||
|
char buf[512] = "zZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY123-4560789.";
|
||||||
|
|
||||||
|
strcat(buf, topdomain);
|
||||||
|
send_query(fd, buf);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
handshake(int dns_fd)
|
handshake(int dns_fd)
|
||||||
{
|
{
|
||||||
|
@ -446,7 +463,7 @@ perform_login:
|
||||||
client[64] = 0;
|
client[64] = 0;
|
||||||
if (tun_setip(client) == 0 &&
|
if (tun_setip(client) == 0 &&
|
||||||
tun_setmtu(mtu) == 0) {
|
tun_setmtu(mtu) == 0) {
|
||||||
return 0;
|
goto perform_case_check;
|
||||||
} else {
|
} else {
|
||||||
warnx("Received handshake with bad data");
|
warnx("Received handshake with bad data");
|
||||||
}
|
}
|
||||||
|
@ -458,8 +475,57 @@ perform_login:
|
||||||
|
|
||||||
printf("Retrying login...\n");
|
printf("Retrying login...\n");
|
||||||
}
|
}
|
||||||
|
errx(1, "couldn't login to server");
|
||||||
|
/* NOTREACHED */
|
||||||
|
|
||||||
return 1;
|
perform_case_check:
|
||||||
|
case_preserved = 0;
|
||||||
|
for (i=0; running && i<5 ;i++) {
|
||||||
|
tv.tv_sec = i + 1;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
send_case_check(dns_fd);
|
||||||
|
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(dns_fd, &fds);
|
||||||
|
|
||||||
|
r = select(dns_fd + 1, &fds, NULL, NULL, &tv);
|
||||||
|
|
||||||
|
if(r > 0) {
|
||||||
|
read = read_dns(dns_fd, in, sizeof(in));
|
||||||
|
|
||||||
|
if(read <= 0) {
|
||||||
|
warn("read");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read > 0) {
|
||||||
|
if (in[0] == 'z' || in[0] == 'Z') {
|
||||||
|
if (read < (26 * 2)) {
|
||||||
|
printf("Received short case reply...\n");
|
||||||
|
} else {
|
||||||
|
int k;
|
||||||
|
|
||||||
|
case_preserved = 1;
|
||||||
|
for (k = 0; k < 26 && case_preserved; k += 2) {
|
||||||
|
if (in[k] == in[k+1]) {
|
||||||
|
/* test string: zZaAbBcCdD... */
|
||||||
|
case_preserved = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("Received bad case check reply\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Retrying case check...\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("No reply on case check, continuing\n");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -236,6 +236,12 @@ tunnel_dns(int tun_fd, int dns_fd)
|
||||||
memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query));
|
memcpy(&(users[userid].q), &(dummy.q), sizeof(struct query));
|
||||||
users[userid].last_pkt = time(NULL);
|
users[userid].last_pkt = time(NULL);
|
||||||
}
|
}
|
||||||
|
} else if(in[0] == 'Z' || in[0] == 'z') {
|
||||||
|
/* Case conservation check */
|
||||||
|
|
||||||
|
/* Reply with received hostname as data */
|
||||||
|
write_dns(dns_fd, &(dummy.q), in, read);
|
||||||
|
return 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')) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
/* This is the version of the network protocol
|
/* This is the version of the network protocol
|
||||||
It is usually equal to the latest iodine version number */
|
It is usually equal to the latest iodine version number */
|
||||||
#define VERSION 0x00000401
|
#define VERSION 0x00000402
|
||||||
|
|
||||||
#endif /* _VERSION_H_ */
|
#endif /* _VERSION_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue