forwarded port defaults to player socket address port

This commit is contained in:
Alvsch committed 2024-10-17 00:23:05 +02:00
1 parent 6c9862cce8
commit a863e97368
4 files changed
+38 -19

No files matched your search

+4 -1
View File
@@ -20,7 +20,10 @@ use uuid::Uuid;
use crate::{ use crate::{
client::authentication::{self, validate_textures, GameProfile}, client::authentication::{self, validate_textures, GameProfile},
entity::player::{ChatMode, Hand}, entity::player::{ChatMode, Hand},
proxy::{bungeecord::bungeecord_login, velocity::{receive_plugin_response, velocity_login}}, proxy::{
bungeecord::bungeecord_login,
velocity::{receive_plugin_response, velocity_login},
},
server::{Server, CURRENT_MC_VERSION}, server::{Server, CURRENT_MC_VERSION},
}; };
+6 -3
View File
@@ -1,8 +1,11 @@
use std::{ use std::{
collections::VecDeque, io::{self, Write}, net::SocketAddr, sync::{ collections::VecDeque,
io::{self, Write},
net::SocketAddr,
sync::{
atomic::{AtomicBool, AtomicI32}, atomic::{AtomicBool, AtomicI32},
Arc, Arc,
} },
}; };
use crate::{ use crate::{
@@ -394,7 +397,7 @@ impl Client {
dbg!("a"); dbg!("a");
self.kick(&err.to_string()); self.kick(&err.to_string());
break; break;
}, }
} }
} }
dec.clear(); dec.clear();
+1 -1
View File
@@ -221,7 +221,7 @@ fn main() -> io::Result<()> {
)?; )?;
let keep_alive = tokio::sync::mpsc::channel(1024); let keep_alive = tokio::sync::mpsc::channel(1024);
let client = let client =
Arc::new(Client::new(id, connection, addr, keep_alive.0.into())); Arc::new(Client::new(id, connection, address, keep_alive.0.into()));
{ {
let client = client.clone(); let client = client.clone();
+27 -14
View File
@@ -4,11 +4,14 @@ use bytes::{BufMut, BytesMut};
use hmac::{Hmac, Mac}; use hmac::{Hmac, Mac};
use pumpkin_config::proxy::VelocityConfig; use pumpkin_config::proxy::VelocityConfig;
use pumpkin_protocol::{ use pumpkin_protocol::{
bytebuf::ByteBuffer, client::login::{CLoginPluginRequest, CLoginSuccess}, server::login::SLoginPluginResponse, Property bytebuf::ByteBuffer,
client::login::{CLoginPluginRequest, CLoginSuccess},
server::login::SLoginPluginResponse,
Property,
}; };
use sha2::Sha256; use sha2::Sha256;
use crate::client::Client; use crate::client::{authentication::GameProfile, Client};
type HmacSha256 = Hmac<Sha256>; type HmacSha256 = Hmac<Sha256>;
@@ -61,7 +64,10 @@ pub fn receive_plugin_response(
return; return;
} }
// TODO: no unwrap // TODO: no unwrap
let addr: SocketAddr = SocketAddr::new(buf.get_string().unwrap().parse::<IpAddr>().unwrap(), 0); let addr: SocketAddr = SocketAddr::new(
buf.get_string().unwrap().parse::<IpAddr>().unwrap(),
client.address.lock().port(),
);
*client.address.lock() = addr; *client.address.lock() = addr;
@@ -70,19 +76,19 @@ pub fn receive_plugin_response(
let username = buf.get_string().unwrap(); let username = buf.get_string().unwrap();
// Read game profile properties // Read game profile properties
let properties = buf.get_list(|data| { let properties = buf
let name = data.get_string()?; .get_list(|data| {
let value = data.get_string()?; let name = data.get_string()?;
let signature = data.get_option(|data| { let value = data.get_string()?;
data.get_string() let signature = data.get_option(|data| data.get_string())?;
})?;
Ok(Property { Ok(Property {
name, name,
value, value,
signature, signature,
})
}) })
}).unwrap(); .unwrap();
client.send_packet(&CLoginSuccess { client.send_packet(&CLoginSuccess {
uuid: &uuid, uuid: &uuid,
@@ -90,5 +96,12 @@ pub fn receive_plugin_response(
properties: &properties, properties: &properties,
strict_error_handling: false, strict_error_handling: false,
}); });
*client.gameprofile.lock() = Some(GameProfile {
id: uuid,
name: username,
properties,
profile_actions: None,
});
} }
} }