mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
misc fixes
This commit is contained in:
parent
c37fcfe4da
commit
153b5b45e4
3 changed files with 18 additions and 23 deletions
|
@ -11,14 +11,7 @@ use azalea_protocol::{
|
|||
},
|
||||
resolver, ServerAddress,
|
||||
};
|
||||
use std::{
|
||||
borrow::BorrowMut,
|
||||
cell::RefCell,
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
rc::Rc,
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
|
@ -88,8 +81,8 @@ impl Client {
|
|||
|
||||
conn.write(
|
||||
ServerboundKeyPacket {
|
||||
nonce: e.encrypted_nonce.into(),
|
||||
shared_secret: e.encrypted_public_key.into(),
|
||||
nonce: e.encrypted_nonce,
|
||||
shared_secret: e.encrypted_public_key,
|
||||
}
|
||||
.get(),
|
||||
)
|
||||
|
@ -237,6 +230,6 @@ impl Account {
|
|||
}
|
||||
|
||||
pub async fn join(&self, address: &ServerAddress) -> Result<Client, String> {
|
||||
Client::join(&self, address).await
|
||||
Client::join(self, address).await
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ impl<T: McBufWritable> McBufWritable for BrigadierNumber<T> {
|
|||
if self.max.is_some() {
|
||||
flags |= 0x02;
|
||||
}
|
||||
buf.write_i8(flags);
|
||||
buf.write_byte(flags)?;
|
||||
if let Some(min) = &self.min {
|
||||
min.write_into(buf)?;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
use std::{cell::Cell, pin::Pin};
|
||||
use std::{
|
||||
cell::Cell,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use crate::{connect::PacketFlow, mc_buf::Readable, packets::ProtocolPacket};
|
||||
use async_compression::tokio::bufread::ZlibDecoder;
|
||||
|
@ -35,13 +39,13 @@ where
|
|||
{
|
||||
// Packet ID
|
||||
let packet_id = stream.read_varint().await?;
|
||||
Ok(P::read(packet_id.try_into().unwrap(), flow, stream).await?)
|
||||
P::read(packet_id.try_into().unwrap(), flow, stream).await
|
||||
}
|
||||
|
||||
// this is always true in multiplayer, false in singleplayer
|
||||
static VALIDATE_DECOMPRESSED: bool = true;
|
||||
|
||||
pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 8388608;
|
||||
pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 2097152;
|
||||
|
||||
async fn compression_decoder<R>(
|
||||
stream: &mut R,
|
||||
|
@ -103,28 +107,26 @@ where
|
|||
|
||||
impl<R> AsyncRead for EncryptedStream<'_, R>
|
||||
where
|
||||
R: AsyncRead + std::marker::Unpin + std::marker::Send,
|
||||
R: AsyncRead + Unpin + Send,
|
||||
{
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
cx: &mut Context<'_>,
|
||||
buf: &mut tokio::io::ReadBuf<'_>,
|
||||
) -> std::task::Poll<std::io::Result<()>> {
|
||||
) -> Poll<std::io::Result<()>> {
|
||||
// i hate this
|
||||
let polled = self.as_mut().stream.as_mut().poll_read(cx, buf);
|
||||
match polled {
|
||||
std::task::Poll::Ready(r) => {
|
||||
Poll::Ready(r) => {
|
||||
if let Some(cipher) = self.as_mut().cipher.get_mut() {
|
||||
azalea_auth::encryption::decrypt_packet(cipher, buf.initialized_mut());
|
||||
}
|
||||
match r {
|
||||
Ok(()) => std::task::Poll::Ready(Ok(())),
|
||||
Ok(()) => Poll::Ready(Ok(())),
|
||||
Err(e) => panic!("{:?}", e),
|
||||
}
|
||||
}
|
||||
std::task::Poll::Pending => {
|
||||
return std::task::Poll::Pending;
|
||||
}
|
||||
Poll::Pending => Poll::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue