Issue 72: Improve ghost user detection
uhub has the ability to disconnect a 'ghost' user, e.g. if a user reconnects then uhub will kick the existing user if it is still there. However, this could also be triggered abusively by having two "tabs" or windows connect at the same time from the same client. The process of connecting a new client is rather expensive because it triggers a lot of updates on all connections. With this change, uhub will only attempt to disconnect the existing client if it is marked with the "flag_choke" flag, which indicates that messages must be dropped simply because the client is not accepting data fast enough. This will cause the new connection to fail because the user is already logged in. This can be further improved by adding a timestamp for when the connection previously was provable working. Which is possibly a better and more reliable way of detecting ghost users.
This commit is contained in:
parent
78a7039240
commit
cff10910ad
@ -337,9 +337,19 @@ static int check_logged_in(struct hub_info* hub, struct hub_user* user, struct a
|
||||
{
|
||||
if (lookup1 == lookup2)
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is logged in: %s", user->id.nick);
|
||||
hub_disconnect_user(hub, lookup1, quit_ghost_timeout);
|
||||
return 0;
|
||||
if (user_flag_get(lookup1, flag_choke))
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is already logged in, but likely ghost: %s", user->id.nick);
|
||||
|
||||
// Old user unable to swallow data.
|
||||
// Disconnect the existing user, and allow new user to enter.
|
||||
hub_disconnect_user(hub, lookup1, quit_ghost_timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("check_logged_in: exact same user is already logged in: %s", user->id.nick);
|
||||
return status_msg_inf_error_cid_taken;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -82,16 +82,19 @@ static int check_send_queue(struct hub_info* hub, struct hub_user* user, struct
|
||||
|
||||
if ((user->send_queue->size + msg->length) > get_max_send_queue(hub))
|
||||
{
|
||||
user_flag_set(user, flag_choke);
|
||||
LOG_WARN("send queue overflowed, message discarded.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user->send_queue->size > get_max_send_queue_soft(hub))
|
||||
{
|
||||
user_flag_set(user, flag_choke);
|
||||
LOG_WARN("send queue soft overflowed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
user_flag_unset(user, flag_choke);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user