diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 9 | ||||
-rw-r--r-- | src/main.rs | 20 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/config.rs b/src/config.rs index 8bbb052..750475b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,11 @@ use inotify::{EventMask, Inotify, WatchMask}; use log::{error, info}; use serde::{Deserialize, Serialize}; -use std::{fs::read_to_string, net::SocketAddr, sync::{Arc, RwLock}}; +use std::{ + fs::read_to_string, + net::SocketAddr, + sync::{Arc, RwLock}, +}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { @@ -21,7 +25,8 @@ pub fn watch(config: Arc<RwLock<Arc<Config>>>) { std::thread::spawn(move || { let mut inotify = Inotify::init().unwrap(); inotify - .add_watch( + .watches() + .add( ".", WatchMask::MODIFY | WatchMask::CREATE | WatchMask::DELETE, ) diff --git a/src/main.rs b/src/main.rs index 47cec90..db7833c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,13 +5,22 @@ pub mod config; use anyhow::bail; use azalea_protocol::{ packets::{ - handshake::{client_intention_packet::ClientIntentionPacket, ServerboundHandshakePacket}, + handshaking::{client_intention_packet::ClientIntentionPacket, ServerboundHandshakePacket}, login::ServerboundLoginPacket, ConnectionProtocol, }, read::read_packet, write::write_packet, }; +// use azalea_protocol::{ +// packets::{ +// handshake::{client_intention_packet::ClientIntentionPacket, ServerboundHandshakePacket}, +// login::ServerboundLoginPacket, +// ConnectionProtocol, +// }, +// read::read_packet, +// write::write_packet, +// }; use bytes::BytesMut; use config::Config; use log::{error, info, warn}; @@ -108,24 +117,25 @@ async fn handle_client(config: Arc<Config>, sock: TcpStream) -> Result<(), anyho .await?; let upstream_login = match login { ServerboundLoginPacket::Hello(mut p) => { - info!("client hello (username={:?})", p.username); + info!("client hello (username={:?})", p.name); let profile = config .whitelist .iter() - .find(|e| e.token.as_ref().map_or(false, |e| e == &p.username)); + .find(|e| e.token.as_ref().map_or(false, |e| e == &p.name)); match profile { Some(profile) => { info!("login as {:?}", profile.username); - p.username = profile.username.clone(); + p.name = profile.username.clone(); } None => bail!("no profile found, disconnecting client"), } p } + ServerboundLoginPacket::LoginAcknowledged(_) => bail!("wtf?"), ServerboundLoginPacket::Key(_) => bail!("key not supported"), - ServerboundLoginPacket::CustomQuery(_) => bail!("custom query not supported"), + ServerboundLoginPacket::CustomQueryAnswer(_) => bail!("custom query not supported"), }; let upstream = TcpStream::connect(config.backend).await?; |