forwarded port defaults to player socket address port
This commit is contained in:
1 parent
6c9862cce8
commit
a863e97368
4 files changed
+42
-23
No files matched your search
@@ -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},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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();
|
||||||
|
|||||||
@@ -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,28 +64,31 @@ 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;
|
||||||
|
|
||||||
let uuid = buf.get_uuid().unwrap();
|
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 {
|
let username = buf.get_string().unwrap();
|
||||||
name,
|
|
||||||
value,
|
// Read game profile properties
|
||||||
signature,
|
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 {
|
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,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user