aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/server_status_pinger.rs
diff options
context:
space:
mode:
Diffstat (limited to 'minecraft-protocol/src/server_status_pinger.rs')
-rw-r--r--minecraft-protocol/src/server_status_pinger.rs47
1 files changed, 25 insertions, 22 deletions
diff --git a/minecraft-protocol/src/server_status_pinger.rs b/minecraft-protocol/src/server_status_pinger.rs
index ad3d4e52..df53b897 100644
--- a/minecraft-protocol/src/server_status_pinger.rs
+++ b/minecraft-protocol/src/server_status_pinger.rs
@@ -4,7 +4,6 @@ use crate::{
packets::{ClientIntentionPacket, ConnectionProtocol, ServerboundStatusRequestPacket},
resolver, ServerAddress,
};
-use tokio::io::AsyncReadExt;
pub async fn ping_server(address: &ServerAddress) -> Result<(), String> {
let resolved_address = resolver::resolve_address(&address).await?;
@@ -23,25 +22,29 @@ pub async fn ping_server(address: &ServerAddress) -> Result<(), String> {
.await;
conn.send_packet(&ServerboundStatusRequestPacket {}).await;
- let data = mc_buf::read_varint(conn.stream);
- println!("data {}", data);
-
- // log what the server sends back
- loop {
- if 0 == conn.stream.read_buf(&mut conn.buffer).await.unwrap() {
- // The remote closed the connection. For this to be a clean
- // shutdown, there should be no data in the read buffer. If
- // there is, this means that the peer closed the socket while
- // sending a frame.
-
- // log conn.buffer
- println!("{:?}", conn.buffer);
- if conn.buffer.is_empty() {
- println!("buffer is empty ok");
- return Ok(());
- } else {
- return Err("connection reset by peer".into());
- }
- }
- }
+ conn.read_packet().await.unwrap();
+
+ Ok(())
+
+ // let data = mc_buf::read_varint(conn.stream);
+ // println!("data {}", data);
+
+ // // log what the server sends back
+ // loop {
+ // if 0 == conn.stream.read_buf(&mut conn.buffer).await.unwrap() {
+ // // The remote closed the connection. For this to be a clean
+ // // shutdown, there should be no data in the read buffer. If
+ // // there is, this means that the peer closed the socket while
+ // // sending a frame.
+
+ // // log conn.buffer
+ // println!("{:?}", conn.buffer);
+ // if conn.buffer.is_empty() {
+ // println!("buffer is empty ok");
+ // return Ok(());
+ // } else {
+ // return Err("connection reset by peer".into());
+ // }
+ // }
+ // }
}