forwarded port defaults to player socket address port
This commit is contained in:
parent
6c9862cce8
commit
a863e97368
@ -20,7 +20,10 @@ use uuid::Uuid;
|
||||
use crate::{
|
||||
client::authentication::{self, validate_textures, GameProfile},
|
||||
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},
|
||||
};
|
||||
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
use std::{
|
||||
collections::VecDeque, io::{self, Write}, net::SocketAddr, sync::{
|
||||
collections::VecDeque,
|
||||
io::{self, Write},
|
||||
net::SocketAddr,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicI32},
|
||||
Arc,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@ -394,7 +397,7 @@ impl Client {
|
||||
dbg!("a");
|
||||
self.kick(&err.to_string());
|
||||
break;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
dec.clear();
|
||||
|
||||
@ -221,7 +221,7 @@ fn main() -> io::Result<()> {
|
||||
)?;
|
||||
let keep_alive = tokio::sync::mpsc::channel(1024);
|
||||
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();
|
||||
|
||||
@ -4,11 +4,14 @@ use bytes::{BufMut, BytesMut};
|
||||
use hmac::{Hmac, Mac};
|
||||
use pumpkin_config::proxy::VelocityConfig;
|
||||
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 crate::client::Client;
|
||||
use crate::client::{authentication::GameProfile, Client};
|
||||
|
||||
type HmacSha256 = Hmac<Sha256>;
|
||||
|
||||
@ -61,28 +64,31 @@ pub fn receive_plugin_response(
|
||||
return;
|
||||
}
|
||||
// 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;
|
||||
|
||||
let uuid = buf.get_uuid().unwrap();
|
||||
|
||||
let username = buf.get_string().unwrap();
|
||||
|
||||
// Read game profile properties
|
||||
let properties = buf.get_list(|data| {
|
||||
let name = data.get_string()?;
|
||||
let value = data.get_string()?;
|
||||
let signature = data.get_option(|data| {
|
||||
data.get_string()
|
||||
})?;
|
||||
|
||||
Ok(Property {
|
||||
name,
|
||||
value,
|
||||
signature,
|
||||
let username = buf.get_string().unwrap();
|
||||
|
||||
// Read game profile properties
|
||||
let properties = buf
|
||||
.get_list(|data| {
|
||||
let name = data.get_string()?;
|
||||
let value = data.get_string()?;
|
||||
let signature = data.get_option(|data| data.get_string())?;
|
||||
|
||||
Ok(Property {
|
||||
name,
|
||||
value,
|
||||
signature,
|
||||
})
|
||||
})
|
||||
}).unwrap();
|
||||
.unwrap();
|
||||
|
||||
client.send_packet(&CLoginSuccess {
|
||||
uuid: &uuid,
|
||||
@ -90,5 +96,12 @@ pub fn receive_plugin_response(
|
||||
properties: &properties,
|
||||
strict_error_handling: false,
|
||||
});
|
||||
|
||||
*client.gameprofile.lock() = Some(GameProfile {
|
||||
id: uuid,
|
||||
name: username,
|
||||
properties,
|
||||
profile_actions: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user