aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-22 13:06:33 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-22 13:06:33 +0200
commitd08051a8bc584988530922aea02dcd0098e40d9a (patch)
treee0d0ed39f2003e84375c8f47c3bd880a7d6a6efc /src
parent6e50a340ca698ed94c11cfb156e3f5e498807e4d (diff)
downloadtrash-proxy-d08051a8bc584988530922aea02dcd0098e40d9a.tar
trash-proxy-d08051a8bc584988530922aea02dcd0098e40d9a.tar.bz2
trash-proxy-d08051a8bc584988530922aea02dcd0098e40d9a.tar.zst
update all the stuff
Diffstat (limited to 'src')
-rw-r--r--src/config.rs9
-rw-r--r--src/main.rs20
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?;