Fix stale client rejection and terminal cursor mode
This commit is contained in:
+15
-1
@@ -226,6 +226,11 @@ async fn handle_packet(
|
||||
handle_ticket_attach(state, socket, peer, packet.body).await
|
||||
}
|
||||
PacketKind::ResumeRequest => handle_resume(state, socket, peer, &packet).await,
|
||||
PacketKind::Input | PacketKind::Resize | PacketKind::Ping | PacketKind::Ack
|
||||
if find_client_key(state, &packet.header.conn_id).is_err() =>
|
||||
{
|
||||
send_reject_to_client(socket, peer, packet.header.conn_id, "unknown client").await
|
||||
}
|
||||
PacketKind::Input => handle_input(state, peer, &packet).await,
|
||||
PacketKind::Resize => handle_resize(state, peer, &packet).await,
|
||||
PacketKind::Ping => handle_ping(state, socket, peer, &packet).await,
|
||||
@@ -425,10 +430,19 @@ async fn handle_ticket_attach(
|
||||
}
|
||||
|
||||
async fn send_reject(socket: &UdpSocket, peer: SocketAddr, reason: &str) -> Result<()> {
|
||||
send_reject_to_client(socket, peer, [0u8; 16], reason).await
|
||||
}
|
||||
|
||||
async fn send_reject_to_client(
|
||||
socket: &UdpSocket,
|
||||
peer: SocketAddr,
|
||||
client_id: [u8; 16],
|
||||
reason: &str,
|
||||
) -> Result<()> {
|
||||
let body = protocol::to_body(&AttachReject {
|
||||
reason: reason.to_string(),
|
||||
})?;
|
||||
let out = protocol::encode_plain(PacketKind::AttachReject, [0u8; 16], 0, 0, &body)?;
|
||||
let out = protocol::encode_plain(PacketKind::AttachReject, client_id, 0, 0, &body)?;
|
||||
socket.send_to(&out, peer).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user