Prevent spoofing moderator packets (#86)

This commit is contained in:
Isaac 2022-05-10 19:27:29 +10:00 committed by GitHub
parent 780249ab21
commit f552e98cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -52,7 +52,7 @@ void packet_process(struct Packet* p) {
case PACKET_CHAT: network_receive_chat(p); break;
case PACKET_KICK: network_receive_kick(p); break;
case PACKET_COMMAND: network_recieve_chat_command(p); break;
case PACKET_MODERATOR: network_recieve_moderator(); break;
case PACKET_MODERATOR: network_recieve_moderator(p); break;
case PACKET_KEEP_ALIVE: network_receive_keep_alive(p); break;
case PACKET_LEAVING: network_receive_leaving(p); break;
case PACKET_SAVE_FILE: network_receive_save_file(p); break;

View File

@ -247,7 +247,7 @@ void network_recieve_chat_command(struct Packet* p);
// packet_moderator.c
void network_send_moderator(u8 localIndex);
void network_recieve_moderator(void);
void network_recieve_moderator(struct Packet* p);
// packet_keep_alive.c
void network_send_keep_alive(u8 localIndex);

View File

@ -52,10 +52,15 @@ void network_send_moderator(u8 localIndex) {
network_send_to(localIndex, &p);
}
void network_recieve_moderator(void) {
void network_recieve_moderator(struct Packet* p) {
if (gIsModerator == 1) {
return;
}
if (network_player_any_connected() && gNetworkPlayers[p->localIndex].type != NPT_SERVER) {
return;
}
gIsModerator = 1;
djui_chat_message_create("\\#fff982\\You are now a Moderator.");
}