diff options
| author | mat <github@matdoes.dev> | 2021-12-15 23:10:55 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-15 23:10:55 -0600 |
| commit | 9642558f8f8d983a7087f15d68be8cf07a85f0c2 (patch) | |
| tree | 5f0a967f005cd5db510a13ab290c8ad6669b25aa /minecraft-client/src/ping.rs | |
| parent | 72aefe871ca4983431b1a0b707b472e73ffea836 (diff) | |
| download | azalea-drasl-9642558f8f8d983a7087f15d68be8cf07a85f0c2.tar.xz | |
azalea
Diffstat (limited to 'minecraft-client/src/ping.rs')
| -rw-r--r-- | minecraft-client/src/ping.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/minecraft-client/src/ping.rs b/minecraft-client/src/ping.rs deleted file mode 100644 index ff869d4e..00000000 --- a/minecraft-client/src/ping.rs +++ /dev/null @@ -1,44 +0,0 @@ -///! Ping Minecraft servers. -use minecraft_protocol::{ - connect::HandshakeConnection, - packets::{ - handshake::client_intention_packet::ClientIntentionPacket, - status::{ - clientbound_status_response_packet::ClientboundStatusResponsePacket, - serverbound_status_request_packet::ServerboundStatusRequestPacket, StatusPacket, - }, - ConnectionProtocol, PROTOCOL_VERSION, - }, - resolver, ServerAddress, -}; - -pub async fn ping_server( - address: &ServerAddress, -) -> Result<ClientboundStatusResponsePacket, String> { - let resolved_address = resolver::resolve_address(address).await?; - - let mut conn = HandshakeConnection::new(&resolved_address).await?; - - // send the client intention packet and switch to the status state - conn.write( - ClientIntentionPacket { - protocol_version: PROTOCOL_VERSION, - hostname: address.host.clone(), - port: address.port, - intention: ConnectionProtocol::Status, - } - .get(), - ) - .await; - let mut conn = conn.status(); - - // send the empty status request packet - conn.write(ServerboundStatusRequestPacket {}.get()).await; - - let packet = conn.read().await.unwrap(); - - match packet { - StatusPacket::ClientboundStatusResponsePacket(p) => Ok(*p), - _ => Err("Invalid packet type".to_string()), - } -} |
