Report online mode error if lobby receives server encryption request
This commit is contained in:
@@ -234,7 +234,7 @@ async fn drain_forge_responses(
|
|||||||
// TODO: instantly return on this packet?
|
// TODO: instantly return on this packet?
|
||||||
// // Hijack login success
|
// // Hijack login success
|
||||||
// if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
// if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
||||||
// trace!(target: "lazymc::forge", "Received login success from server connection, change to play mode");
|
// trace!(target: "lazymc::forge", "Got login success from server connection, change to play mode");
|
||||||
|
|
||||||
// // Switch to play state
|
// // Switch to play state
|
||||||
// tmp_client.set_state(ClientState::Play);
|
// tmp_client.set_state(ClientState::Play);
|
||||||
@@ -243,7 +243,7 @@ async fn drain_forge_responses(
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::forge", "Received unhandled packet from server in record_forge_response:");
|
debug!(target: "lazymc::forge", "Got unhandled packet from server in record_forge_response:");
|
||||||
debug!(target: "lazymc::forge", "- State: {:?}", client_state);
|
debug!(target: "lazymc::forge", "- State: {:?}", client_state);
|
||||||
debug!(target: "lazymc::forge", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::forge", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
|
29
src/lobby.rs
29
src/lobby.rs
@@ -170,7 +170,7 @@ pub async fn serve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc", "Received unhandled packet:");
|
debug!(target: "lazymc", "Got unhandled packet:");
|
||||||
debug!(target: "lazymc", "- State: {:?}", client_state);
|
debug!(target: "lazymc", "- State: {:?}", client_state);
|
||||||
debug!(target: "lazymc", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
@@ -464,6 +464,18 @@ async fn connect_to_server_no_timeout(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Catch encryption requests
|
||||||
|
if client_state == ClientState::Login
|
||||||
|
&& packet.id == packets::login::CLIENT_ENCRYPTION_REQUEST
|
||||||
|
{
|
||||||
|
error!(
|
||||||
|
target: "lazymc::lobby",
|
||||||
|
"Got encryption request from server, this is unsupported. Server must be in offline mode to use lobby.",
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Hijack login plugin request
|
// Hijack login plugin request
|
||||||
if client_state == ClientState::Login
|
if client_state == ClientState::Login
|
||||||
&& packet.id == packets::login::CLIENT_LOGIN_PLUGIN_REQUEST
|
&& packet.id == packets::login::CLIENT_LOGIN_PLUGIN_REQUEST
|
||||||
@@ -476,7 +488,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
|
|
||||||
// Respond with Forge messages
|
// Respond with Forge messages
|
||||||
if config.server.forge {
|
if config.server.forge {
|
||||||
trace!(target: "lazymc::lobby", "Received login plugin request from server, responding with Forge reply");
|
trace!(target: "lazymc::lobby", "Got login plugin request from server, responding with Forge reply");
|
||||||
|
|
||||||
// Respond to Forge login plugin request
|
// Respond to Forge login plugin request
|
||||||
forge::respond_login_plugin_request(&tmp_client, plugin_request, &mut writer)
|
forge::respond_login_plugin_request(&tmp_client, plugin_request, &mut writer)
|
||||||
@@ -485,7 +497,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!(target: "lazymc::lobby", "Received unexpected login plugin request from server, you may need to enable Forge support");
|
warn!(target: "lazymc::lobby", "Got unexpected login plugin request from server, you may need to enable Forge support");
|
||||||
|
|
||||||
// Write unsuccesful login plugin response
|
// Write unsuccesful login plugin response
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
@@ -504,7 +516,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
|
|
||||||
// Hijack login success
|
// Hijack login success
|
||||||
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
||||||
trace!(target: "lazymc::lobby", "Received login success from server connection, change to play mode");
|
trace!(target: "lazymc::lobby", "Got login success from server connection, change to play mode");
|
||||||
|
|
||||||
// TODO: parse this packet to ensure it's fine
|
// TODO: parse this packet to ensure it's fine
|
||||||
// let login_success =
|
// let login_success =
|
||||||
@@ -526,7 +538,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
|
|
||||||
// Hijack disconnect
|
// Hijack disconnect
|
||||||
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_DISCONNECT {
|
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_DISCONNECT {
|
||||||
error!(target: "lazymc::lobby", "Received disconnect from server connection");
|
error!(target: "lazymc::lobby", "Got disconnect from server connection");
|
||||||
|
|
||||||
// // Decode disconnect packet
|
// // Decode disconnect packet
|
||||||
// let login_disconnect =
|
// let login_disconnect =
|
||||||
@@ -539,11 +551,8 @@ async fn connect_to_server_no_timeout(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if receiving encryption request, disconnect with error because we don't support
|
|
||||||
// online mode!
|
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::lobby", "Received unhandled packet from server in connect_to_server:");
|
debug!(target: "lazymc::lobby", "Got unhandled packet from server in connect_to_server:");
|
||||||
debug!(target: "lazymc::lobby", "- State: {:?}", client_state);
|
debug!(target: "lazymc::lobby", "- State: {:?}", client_state);
|
||||||
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
@@ -608,7 +617,7 @@ async fn wait_for_server_join_game_no_timeout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::lobby", "Received unhandled packet from server in wait_for_server_join_game:");
|
debug!(target: "lazymc::lobby", "Got unhandled packet from server in wait_for_server_join_game:");
|
||||||
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -249,7 +249,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!(target: "lazymc::probe", "Received unexpected login plugin request, responding with error");
|
warn!(target: "lazymc::probe", "Got unexpected login plugin request, responding with error");
|
||||||
|
|
||||||
// Respond with plugin response failure
|
// Respond with plugin response failure
|
||||||
packet::write_packet(
|
packet::write_packet(
|
||||||
@@ -268,7 +268,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
|
|
||||||
// Hijack login success
|
// Hijack login success
|
||||||
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
if client_state == ClientState::Login && packet.id == packets::login::CLIENT_LOGIN_SUCCESS {
|
||||||
trace!(target: "lazymc::probe", "Received login success from server connection, change to play mode");
|
trace!(target: "lazymc::probe", "Got login success from server connection, change to play mode");
|
||||||
|
|
||||||
// Switch to play state
|
// Switch to play state
|
||||||
tmp_client.set_state(ClientState::Play);
|
tmp_client.set_state(ClientState::Play);
|
||||||
@@ -286,7 +286,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::forge", "Received unhandled packet from server in connect_to_server:");
|
debug!(target: "lazymc::forge", "Got unhandled packet from server in connect_to_server:");
|
||||||
debug!(target: "lazymc::forge", "- State: {:?}", client_state);
|
debug!(target: "lazymc::forge", "- State: {:?}", client_state);
|
||||||
debug!(target: "lazymc::forge", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::forge", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ async fn wait_for_server_join_game_no_timeout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc::lobby", "Received unhandled packet from server in wait_for_server_join_game:");
|
debug!(target: "lazymc::lobby", "Got unhandled packet from server in wait_for_server_join_game:");
|
||||||
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
debug!(target: "lazymc::lobby", "- Packet ID: 0x{:02X} ({})", packet.id, packet.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,8 @@ pub mod login {
|
|||||||
pub const CLIENT_DISCONNECT: u8 = LoginDisconnect::PACKET_ID;
|
pub const CLIENT_DISCONNECT: u8 = LoginDisconnect::PACKET_ID;
|
||||||
pub const CLIENT_LOGIN_SUCCESS: u8 = LoginSuccess::PACKET_ID;
|
pub const CLIENT_LOGIN_SUCCESS: u8 = LoginSuccess::PACKET_ID;
|
||||||
pub const CLIENT_SET_COMPRESSION: u8 = SetCompression::PACKET_ID;
|
pub const CLIENT_SET_COMPRESSION: u8 = SetCompression::PACKET_ID;
|
||||||
|
#[cfg(feature = "lobby")]
|
||||||
|
pub const CLIENT_ENCRYPTION_REQUEST: u8 = EncryptionRequest::PACKET_ID;
|
||||||
pub const CLIENT_LOGIN_PLUGIN_REQUEST: u8 = LoginPluginRequest::PACKET_ID;
|
pub const CLIENT_LOGIN_PLUGIN_REQUEST: u8 = LoginPluginRequest::PACKET_ID;
|
||||||
pub const SERVER_LOGIN_START: u8 = LoginStart::PACKET_ID;
|
pub const SERVER_LOGIN_START: u8 = LoginStart::PACKET_ID;
|
||||||
#[cfg(feature = "lobby")]
|
#[cfg(feature = "lobby")]
|
||||||
|
@@ -189,7 +189,7 @@ pub async fn serve(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show unhandled packet warning
|
// Show unhandled packet warning
|
||||||
debug!(target: "lazymc", "Received unhandled packet:");
|
debug!(target: "lazymc", "Got unhandled packet:");
|
||||||
debug!(target: "lazymc", "- State: {:?}", client_state);
|
debug!(target: "lazymc", "- State: {:?}", client_state);
|
||||||
debug!(target: "lazymc", "- Packet ID: {}", packet.id);
|
debug!(target: "lazymc", "- Packet ID: {}", packet.id);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user