removed goto from username loop & implemented WHY2_MAX_USERNAME_TRIES
This commit is contained in:
parent
31db7c0622
commit
b21d39a35e
@ -379,10 +379,11 @@ void *why2_communicate_thread(void *arg)
|
|||||||
char *raw;
|
char *raw;
|
||||||
void *raw_ptr = NULL;
|
void *raw_ptr = NULL;
|
||||||
why2_bool force_exiting = 0;
|
why2_bool force_exiting = 0;
|
||||||
why2_bool invalid_username;
|
why2_bool invalid_username = 1;
|
||||||
why2_bool exiting = 0;
|
why2_bool exiting = 0;
|
||||||
char *decoded_buffer = NULL;
|
char *decoded_buffer = NULL;
|
||||||
char *username = node.username;
|
char *username = node.username;
|
||||||
|
int usernames_n = 0;
|
||||||
|
|
||||||
why2_deallocate(string_buffer);
|
why2_deallocate(string_buffer);
|
||||||
|
|
||||||
@ -390,9 +391,8 @@ void *why2_communicate_thread(void *arg)
|
|||||||
{
|
{
|
||||||
if (config_username == NULL) fprintf(stderr, "Your config doesn't contain 'user_pick_username'. Please update your configuration.\n");
|
if (config_username == NULL) fprintf(stderr, "Your config doesn't contain 'user_pick_username'. Please update your configuration.\n");
|
||||||
|
|
||||||
repeat_username_get:
|
while (invalid_username)
|
||||||
invalid_username = 0;
|
{
|
||||||
|
|
||||||
why2_send_socket(WHY2_CHAT_CODE_PICK_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //ASK USER FOR USERNAME
|
why2_send_socket(WHY2_CHAT_CODE_PICK_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //ASK USER FOR USERNAME
|
||||||
|
|
||||||
if ((raw = read_user(connection, &raw_ptr)) == NULL) //READ
|
if ((raw = read_user(connection, &raw_ptr)) == NULL) //READ
|
||||||
@ -415,7 +415,13 @@ void *why2_communicate_thread(void *arg)
|
|||||||
if (invalid_username)
|
if (invalid_username)
|
||||||
{
|
{
|
||||||
why2_send_socket(WHY2_CHAT_CODE_INVALID_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //TELL THE USER HE IS DUMB AS FUCK
|
why2_send_socket(WHY2_CHAT_CODE_INVALID_USERNAME, WHY2_CHAT_SERVER_USERNAME, connection); //TELL THE USER HE IS DUMB AS FUCK
|
||||||
goto repeat_username_get; //REPEAT
|
}
|
||||||
|
|
||||||
|
if (++usernames_n == WHY2_MAX_USERNAME_TRIES) //ASKED CLIENT WAY TOO FUCKING MANY TIMES FOR USERNAME, KICK HIM
|
||||||
|
{
|
||||||
|
exiting = 1;
|
||||||
|
goto deallocation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user