Finish server login and stub configuration
This commit is contained in:
parent
d5a87ed4f5
commit
7fc1c70292
2
asn1der.txt
Normal file
2
asn1der.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
reference 30819F300D06092A864886F70D010101050003818D0030818902818100E74798B642B8B855C6C24C32E49B7B842F02739F74BDC0F206C606D28B95BE63B4CC0BB263A038A27B9D2BCDA1375A2E91D3106938FCDC735DE8639C67FC03C8F45E1937390EAE7B358F39DC0C731627B614A61CB6B37F51FD4068149E9A29A854B913FA2DBA529D651BEAF67EEE65BF1019720F0D000C777DB4CE61062E911D0203010001
|
||||||
|
ours 30819506092A864886F70D0101010500028180A43795E1BF36BDA93EFAE6EC1EBF638BBA0B3075F0FCA2B54A822C756BE9B6A9F959D64EB1EB32EC54179A659D3D25A16DF7258CCFCD886C2BDA3556455073D0282C25CED058FDAC7AA9C99631D071CAAFA1D2D7AD178C6DFE480D9B5D9BF7485F136F0AE07653851D48323D614EB72EE6559895AF1D695467A0D90D2469D4510203010001
|
@ -10,3 +10,5 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
EULA: "TRUE"
|
EULA: "TRUE"
|
||||||
VERSION: "1.21.1"
|
VERSION: "1.21.1"
|
||||||
|
ONLINE_MODE: "false"
|
||||||
|
NETWORK_COMPRESSION_THRESHOLD: "-1"
|
||||||
|
@ -10,6 +10,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
use tracing::trace;
|
||||||
|
|
||||||
/// The connection's current state.
|
/// The connection's current state.
|
||||||
/// Similar to crate::protocol::ClientState,
|
/// Similar to crate::protocol::ClientState,
|
||||||
@ -126,7 +127,7 @@ impl DownstreamConnection {
|
|||||||
let login_start = self.read_specific_packet::<LoginStart>().await?;
|
let login_start = self.read_specific_packet::<LoginStart>().await?;
|
||||||
|
|
||||||
// Enable encryption and authenticate with Mojang.
|
// Enable encryption and authenticate with Mojang.
|
||||||
self.enable_encryption().await?;
|
// self.enable_encryption().await?;
|
||||||
|
|
||||||
// Enable compression.
|
// Enable compression.
|
||||||
self.enable_compression().await?;
|
self.enable_compression().await?;
|
||||||
@ -193,6 +194,8 @@ impl DownstreamConnection {
|
|||||||
.expect("failed to decrypt shared secret");
|
.expect("failed to decrypt shared secret");
|
||||||
|
|
||||||
// Enable encryption on the connection.
|
// Enable encryption on the connection.
|
||||||
|
trace!("Enabling encryption for connection {}", self.inner.id);
|
||||||
|
todo!("Fix AES encryption implementation");
|
||||||
let encryptor =
|
let encryptor =
|
||||||
Aes128Cfb8Encryptor::new((&(*shared_secret)).into(), (&(*shared_secret)).into());
|
Aes128Cfb8Encryptor::new((&(*shared_secret)).into(), (&(*shared_secret)).into());
|
||||||
let decryptor =
|
let decryptor =
|
||||||
@ -212,7 +215,10 @@ impl DownstreamConnection {
|
|||||||
self.inner.send_packet(packet).await
|
self.inner.send_packet(packet).await
|
||||||
}
|
}
|
||||||
pub async fn disconnect(&mut self, reason: Option<Chat>) -> Result<(), Error> {
|
pub async fn disconnect(&mut self, reason: Option<Chat>) -> Result<(), Error> {
|
||||||
use packets::{login::clientbound::LoginDisconnect, play::clientbound::PlayDisconnect};
|
use packets::{
|
||||||
|
configuration::clientbound::ConfigurationDisconnect,
|
||||||
|
login::clientbound::LoginDisconnect, play::clientbound::PlayDisconnect,
|
||||||
|
};
|
||||||
|
|
||||||
// let reason = reason.unwrap_or(serde_json::json!({
|
// let reason = reason.unwrap_or(serde_json::json!({
|
||||||
// "text": "You have been disconnected!"
|
// "text": "You have been disconnected!"
|
||||||
@ -226,6 +232,9 @@ impl DownstreamConnection {
|
|||||||
ClientState::Login => {
|
ClientState::Login => {
|
||||||
let _ = self.send_packet(LoginDisconnect { reason }).await;
|
let _ = self.send_packet(LoginDisconnect { reason }).await;
|
||||||
}
|
}
|
||||||
|
ClientState::Configuration => {
|
||||||
|
let _ = self.send_packet(ConfigurationDisconnect { reason }).await;
|
||||||
|
}
|
||||||
ClientState::Play => {
|
ClientState::Play => {
|
||||||
let _ = self.send_packet(PlayDisconnect { reason }).await;
|
let _ = self.send_packet(PlayDisconnect { reason }).await;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ pub enum ClientState {
|
|||||||
///
|
///
|
||||||
/// The `Login` state includes authentication, encryption, compression, and plugins.
|
/// The `Login` state includes authentication, encryption, compression, and plugins.
|
||||||
Login,
|
Login,
|
||||||
|
/// The client is in the `Configuration` state.
|
||||||
|
Configuration,
|
||||||
/// The main connection state. The client has authenticated and is playing on the server.
|
/// The main connection state. The client has authenticated and is playing on the server.
|
||||||
Play,
|
Play,
|
||||||
/// The client has disconnected, and the connection struct should be removed. No packets should be sent or received.
|
/// The client has disconnected, and the connection struct should be removed. No packets should be sent or received.
|
||||||
|
@ -110,7 +110,7 @@ macro_rules! packets {
|
|||||||
pub fn state_change(&self) -> Option<ClientState> {
|
pub fn state_change(&self) -> Option<ClientState> {
|
||||||
match self {
|
match self {
|
||||||
Packet::Handshake(handshake) => Some(handshake.next_state),
|
Packet::Handshake(handshake) => Some(handshake.next_state),
|
||||||
Packet::LoginSuccess(_) => Some(ClientState::Play),
|
Packet::LoginAcknowledged(_) => Some(ClientState::Configuration),
|
||||||
Packet::LoginDisconnect(_) => Some(ClientState::Disconnected),
|
Packet::LoginDisconnect(_) => Some(ClientState::Disconnected),
|
||||||
Packet::PlayDisconnect(_) => Some(ClientState::Disconnected),
|
Packet::PlayDisconnect(_) => Some(ClientState::Disconnected),
|
||||||
Packet::PingResponse(_) => Some(ClientState::Disconnected),
|
Packet::PingResponse(_) => Some(ClientState::Disconnected),
|
||||||
@ -205,7 +205,12 @@ packets!(
|
|||||||
}
|
}
|
||||||
packet LoginPluginResponse 0x02 {
|
packet LoginPluginResponse 0x02 {
|
||||||
field message_id: VarInt,
|
field message_id: VarInt,
|
||||||
field successful: bool,
|
// TODO: Implement
|
||||||
|
rest data,
|
||||||
|
}
|
||||||
|
packet LoginAcknowledged 0x03 {}
|
||||||
|
packet LoginCookieResponse 0x04 {
|
||||||
|
// TODO: Implement
|
||||||
rest data,
|
rest data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +227,7 @@ packets!(
|
|||||||
packet LoginSuccess 0x02 {
|
packet LoginSuccess 0x02 {
|
||||||
field uuid: Uuid,
|
field uuid: Uuid,
|
||||||
field username: String,
|
field username: String,
|
||||||
// TODO: Re-implement CL02LoginSuccessProperty
|
// TODO: Implement
|
||||||
rest properties,
|
rest properties,
|
||||||
}
|
}
|
||||||
packet SetCompression 0x03 {
|
packet SetCompression 0x03 {
|
||||||
@ -231,8 +236,21 @@ packets!(
|
|||||||
packet LoginPluginRequest 0x04 {
|
packet LoginPluginRequest 0x04 {
|
||||||
field message_id: VarInt,
|
field message_id: VarInt,
|
||||||
field channel: String,
|
field channel: String,
|
||||||
|
// TODO: Implement
|
||||||
rest data,
|
rest data,
|
||||||
}
|
}
|
||||||
|
packet LoginCookieRequest 0x05 {
|
||||||
|
// TODO: Implement
|
||||||
|
rest data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
configuration Configuration {
|
||||||
|
serverbound Serverbound {}
|
||||||
|
clientbound Clientbound {
|
||||||
|
packet ConfigurationDisconnect 0x02 {
|
||||||
|
field reason: Chat,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
play Play {
|
play Play {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user