mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-22 13:23:32 +02:00
Merge branch 'protect-options' of https://github.com/Masaq-/iodine into protect_opts
This commit is contained in:
commit
72bdf7f20e
3 changed files with 19 additions and 3 deletions
|
@ -254,6 +254,18 @@ static int check_authenticated_user_and_ip(int userid, struct query *q)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int check_authenticated_user_and_ip_and_options(int userid, struct query *q)
|
||||
{
|
||||
int res = check_authenticated_user_and_ip(userid, q);
|
||||
if (res || check_ip)
|
||||
return res;
|
||||
|
||||
if (users[userid].options_locked)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void send_raw(int fd, char *buf, int buflen, int user, int cmd, struct query *q)
|
||||
{
|
||||
char packet[4096];
|
||||
|
@ -955,7 +967,7 @@ handle_null_request(int tun_fd, int dns_fd, struct dnsfd *dns_fds, struct query
|
|||
|
||||
userid = b32_8to5(in[1]);
|
||||
|
||||
if (check_authenticated_user_and_ip(userid, q) != 0) {
|
||||
if (check_authenticated_user_and_ip_and_options(userid, q) != 0) {
|
||||
write_dns(dns_fd, q, "BADIP", 5, 'T');
|
||||
return; /* illegal id */
|
||||
}
|
||||
|
@ -996,7 +1008,7 @@ handle_null_request(int tun_fd, int dns_fd, struct dnsfd *dns_fds, struct query
|
|||
|
||||
userid = b32_8to5(in[1]);
|
||||
|
||||
if (check_authenticated_user_and_ip(userid, q) != 0) {
|
||||
if (check_authenticated_user_and_ip_and_options(userid, q) != 0) {
|
||||
write_dns(dns_fd, q, "BADIP", 5, 'T');
|
||||
return; /* illegal id */
|
||||
}
|
||||
|
@ -1159,7 +1171,7 @@ handle_null_request(int tun_fd, int dns_fd, struct dnsfd *dns_fds, struct query
|
|||
|
||||
/* Downstream fragsize packet */
|
||||
userid = unpacked[0];
|
||||
if (check_authenticated_user_and_ip(userid, q) != 0) {
|
||||
if (check_authenticated_user_and_ip_and_options(userid, q) != 0) {
|
||||
write_dns(dns_fd, q, "BADIP", 5, 'T');
|
||||
return; /* illegal id */
|
||||
}
|
||||
|
@ -1169,6 +1181,7 @@ handle_null_request(int tun_fd, int dns_fd, struct dnsfd *dns_fds, struct query
|
|||
write_dns(dns_fd, q, "BADFRAG", 7, users[userid].downenc);
|
||||
} else {
|
||||
users[userid].fragsize = max_frag_size;
|
||||
users[userid].options_locked = 1;
|
||||
write_dns(dns_fd, q, &unpacked[1], 2, users[userid].downenc);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -76,6 +76,7 @@ int init_users(in_addr_t my_ip, int netbits)
|
|||
users[i].disabled = 0;
|
||||
users[i].authenticated = 0;
|
||||
users[i].authenticated_raw = 0;
|
||||
users[i].options_locked = 0;
|
||||
users[i].active = 0;
|
||||
/* Rest is reset on login ('V' packet) */
|
||||
}
|
||||
|
@ -151,6 +152,7 @@ int find_available_user(void)
|
|||
users[i].active = 1;
|
||||
users[i].authenticated = 0;
|
||||
users[i].authenticated_raw = 0;
|
||||
users[i].options_locked = 0;
|
||||
users[i].last_pkt = time(NULL);
|
||||
users[i].fragsize = 4096;
|
||||
users[i].conn = CONN_DNS_NULL;
|
||||
|
|
|
@ -39,6 +39,7 @@ struct tun_user {
|
|||
int active;
|
||||
int authenticated;
|
||||
int authenticated_raw;
|
||||
int options_locked;
|
||||
int disabled;
|
||||
time_t last_pkt;
|
||||
int seed;
|
||||
|
|
Loading…
Reference in a new issue