mirror of
https://github.com/timvisee/lazymc.git
synced 2025-07-26 01:32:00 -07:00
Resolve clippy warnings
This commit is contained in:
13
src/lobby.rs
13
src/lobby.rs
@@ -33,7 +33,7 @@ use crate::server::{Server, State};
|
||||
const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(10);
|
||||
|
||||
/// Auto incrementing ID source for keep alive packets.
|
||||
const KEEP_ALIVE_ID: AtomicU64 = AtomicU64::new(0);
|
||||
static KEEP_ALIVE_ID: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// Timeout for creating new server connection for lobby client.
|
||||
const SERVER_CONNECT_TIMEOUT: Duration = Duration::from_secs(2 * 60);
|
||||
@@ -540,11 +540,11 @@ async fn keep_alive_loop(
|
||||
/// In this stage we wait for the server to come online.
|
||||
///
|
||||
/// During this stage we keep sending keep-alive and title packets to the client to keep it active.
|
||||
async fn stage_wait<'a>(
|
||||
async fn stage_wait(
|
||||
client: &Client,
|
||||
server: &Server,
|
||||
config: &Config,
|
||||
writer: &mut WriteHalf<'a>,
|
||||
writer: &mut WriteHalf<'_>,
|
||||
) -> Result<(), ()> {
|
||||
select! {
|
||||
a = keep_alive_loop(client, writer, config) => a,
|
||||
@@ -555,7 +555,7 @@ async fn stage_wait<'a>(
|
||||
/// Wait for the server to come online.
|
||||
///
|
||||
/// Returns `Ok(())` once the server is online, returns `Err(())` if waiting failed.
|
||||
async fn wait_for_server<'a>(server: &Server, config: &Config) -> Result<(), ()> {
|
||||
async fn wait_for_server(server: &Server, config: &Config) -> Result<(), ()> {
|
||||
debug!(target: "lazymc::lobby", "Waiting on server to come online...");
|
||||
|
||||
// A task to wait for suitable server state
|
||||
@@ -695,7 +695,6 @@ async fn connect_to_server_no_timeout(
|
||||
let set_compression =
|
||||
SetCompression::decode(&mut packet.data.as_slice()).map_err(|err| {
|
||||
dbg!(err);
|
||||
()
|
||||
})?;
|
||||
|
||||
// Client and server compression threshold should match, show warning if not
|
||||
@@ -785,7 +784,7 @@ async fn wait_for_server_join_game_no_timeout(
|
||||
|
||||
loop {
|
||||
// Read packet from stream
|
||||
let (packet, _raw) = match proto::read_packet(&client, buf, &mut reader).await {
|
||||
let (packet, _raw) = match proto::read_packet(client, buf, &mut reader).await {
|
||||
Ok(Some(packet)) => packet,
|
||||
Ok(None) => break,
|
||||
Err(_) => {
|
||||
@@ -839,7 +838,7 @@ pub fn route_proxy(inbound: TcpStream, outbound: TcpStream, inbound_queue: Bytes
|
||||
}
|
||||
|
||||
/// Drain given reader until nothing is left voiding all data.
|
||||
async fn drain_stream<'a>(reader: &mut ReadHalf<'a>) -> Result<(), ()> {
|
||||
async fn drain_stream(reader: &mut ReadHalf<'_>) -> Result<(), ()> {
|
||||
let mut drain_buf = [0; 8 * 1024];
|
||||
loop {
|
||||
match reader.try_read(&mut drain_buf) {
|
||||
|
@@ -134,7 +134,7 @@ async fn send_handshake(
|
||||
handshake.encode(&mut packet).map_err(|_| ())?;
|
||||
|
||||
let raw = RawPacket::new(proto::packets::handshake::SERVER_HANDSHAKE, packet)
|
||||
.encode(&client)
|
||||
.encode(client)
|
||||
.map_err(|_| ())?;
|
||||
stream.write_all(&raw).await.map_err(|_| ())?;
|
||||
|
||||
|
@@ -258,7 +258,7 @@ impl RawPacket {
|
||||
}
|
||||
|
||||
// Read decompressed packet ID
|
||||
return Self::read_packet_id_data(&decompressed);
|
||||
Self::read_packet_id_data(&decompressed)
|
||||
}
|
||||
|
||||
/// Encode packet to raw buffer.
|
||||
|
@@ -330,7 +330,7 @@ impl Server {
|
||||
}
|
||||
|
||||
/// Read last known server status.
|
||||
pub async fn status<'a>(&'a self) -> RwLockReadGuard<'a, Option<ServerStatus>> {
|
||||
pub async fn status(&self) -> RwLockReadGuard<'_, Option<ServerStatus>> {
|
||||
self.status.read().await
|
||||
}
|
||||
|
||||
|
@@ -248,7 +248,6 @@ pub async fn serve(
|
||||
///
|
||||
/// Returns holding status. `true` if client is held and it should be proxied, `false` it was held
|
||||
/// but it timed out.
|
||||
#[must_use]
|
||||
pub async fn hold<'a>(config: &Config, server: &Server) -> Result<bool, ()> {
|
||||
trace!(target: "lazymc", "Started holding client");
|
||||
|
||||
@@ -293,19 +292,19 @@ pub async fn hold<'a>(config: &Config, server: &Server) -> Result<bool, ()> {
|
||||
// Relay client to proxy
|
||||
Ok(true) => {
|
||||
info!(target: "lazymc", "Server ready for held client, relaying to server");
|
||||
return Ok(true);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
// Server stopping/stopped, this shouldn't happen, kick
|
||||
Ok(false) => {
|
||||
warn!(target: "lazymc", "Server stopping for held client");
|
||||
return Ok(false);
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
// Timeout reached, kick with starting message
|
||||
Err(_) => {
|
||||
warn!(target: "lazymc", "Held client reached timeout of {}s", config.join.hold.timeout);
|
||||
return Ok(false);
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user