mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-25 02:55:15 +00:00
Modified qmem for lazy mode handling; fixed some user management issues
This commit is contained in:
parent
bd9966836e
commit
555a3cbfe2
10
src/user.c
10
src/user.c
@ -85,6 +85,9 @@ init_users(in_addr_t my_ip, int netbits)
|
||||
}
|
||||
users[i].tun_ip = ip;
|
||||
net.s_addr = ip;
|
||||
|
||||
users[i].incoming = window_buffer_init(INFRAGBUF_LEN, 10, MAX_FRAGSIZE, WINDOW_RECVING);
|
||||
users[i].outgoing = window_buffer_init(OUTFRAGBUF_LEN, 10, 100, WINDOW_SENDING);
|
||||
/* Rest is reset on login ('V' packet) or already 0 */
|
||||
}
|
||||
|
||||
@ -119,7 +122,7 @@ user_sending(int user)
|
||||
int
|
||||
user_active(int i)
|
||||
{
|
||||
return users[i].active && !users[i].disabled && users[i].last_pkt + 60 > time(NULL);
|
||||
return users[i].active && !users[i].disabled && difftime(time(NULL), users[i].last_pkt) < 60;
|
||||
}
|
||||
|
||||
int
|
||||
@ -131,7 +134,8 @@ all_users_waiting_to_send()
|
||||
*/
|
||||
{
|
||||
for (int i = 0; i < usercount; i++)
|
||||
if (!(user_active(i) && user_sending(i))) return 0;
|
||||
if (user_active(i))
|
||||
if (!user_sending(i)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -142,8 +146,6 @@ find_available_user()
|
||||
/* Not used at all or not used in one minute */
|
||||
if (!user_active(u)) {
|
||||
struct tun_user *user = &users[u];
|
||||
if (user->incoming) window_buffer_destroy(user->incoming);
|
||||
if (user->outgoing) window_buffer_destroy(user->outgoing);
|
||||
/* reset all stats */
|
||||
user->active = 1;
|
||||
user->authenticated = 0;
|
||||
|
12
src/user.h
12
src/user.h
@ -31,11 +31,11 @@ struct tun_user {
|
||||
int authenticated_raw;
|
||||
int disabled;
|
||||
time_t last_pkt;
|
||||
struct timeval dns_timeout;
|
||||
int seed;
|
||||
in_addr_t tun_ip;
|
||||
struct sockaddr_storage host;
|
||||
socklen_t hostlen;
|
||||
struct query q;
|
||||
/* TODO: multiple incoming query storage + handling */
|
||||
struct frag_buffer *incoming;
|
||||
struct frag_buffer *outgoing;
|
||||
@ -43,15 +43,13 @@ struct tun_user {
|
||||
struct encoder *encoder;
|
||||
char downenc;
|
||||
int downenc_bits;
|
||||
int down_compression;
|
||||
int fragsize;
|
||||
enum connection conn;
|
||||
int lazy;
|
||||
/*unsigned char qmemping_cmc[QMEMPING_LEN * 4];
|
||||
unsigned short qmemping_type[QMEMPING_LEN];
|
||||
int qmemping_lastfilled;
|
||||
unsigned char qmemdata_cmc[QMEMDATA_LEN * 4];
|
||||
unsigned short qmemdata_type[QMEMDATA_LEN];
|
||||
int qmemdata_lastfilled;*/
|
||||
#ifdef QMEM_LEN
|
||||
struct query_buffer qmem;
|
||||
#endif
|
||||
#ifdef DNSCACHE_LEN
|
||||
struct query dnscache_q[DNSCACHE_LEN];
|
||||
char dnscache_answer[DNSCACHE_LEN][4096];
|
||||
|
Loading…
Reference in New Issue
Block a user