Do not crash on ctrl close of invalid connection

This commit is contained in:
ChillerDragon 2022-11-13 07:51:50 +01:00
parent 129fa9aed5
commit 409f880f36

View file

@ -149,6 +149,11 @@ class TeeworldsServer
end end
def send_ctrl_close(client, reason) def send_ctrl_close(client, reason)
# when clients disconnect
# during the connection process
# we do not care
return if client.nil?
msg = [NET_CTRLMSG_CLOSE] msg = [NET_CTRLMSG_CLOSE]
msg += Packer.pack_str(reason) unless reason.nil? msg += Packer.pack_str(reason) unless reason.nil?
@netbase.set_peer_token(client.token) @netbase.set_peer_token(client.token)