Added listener::AuthenticationMethod to listener::ProxyInfo
This commit is contained in:
parent
852934cd84
commit
574f9fa567
|
@ -10,14 +10,21 @@ pub enum OnlineStatus {
|
|||
Offline,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub enum AuthenticationMethod {
|
||||
Mojang,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ProxyInfo {
|
||||
pub proxy_addr: String,
|
||||
pub proxy_port: u16,
|
||||
pub online_status: OnlineStatus,
|
||||
pub backend_addr: String,
|
||||
pub backend_port: u16,
|
||||
pub private_key: RsaPrivateKey,
|
||||
pub online_status: OnlineStatus,
|
||||
pub authentication_method: AuthenticationMethod,
|
||||
}
|
||||
|
||||
impl ProxyInfo {
|
||||
|
|
|
@ -175,14 +175,21 @@ async fn check_player(
|
|||
proxy_info.private_key.clone())?;
|
||||
encryption_request.write(client_conn).await?;
|
||||
let encryption_response =
|
||||
login::serverbound::EncryptionResponse::read(client_conn).await?;
|
||||
login::serverbound::EncryptionResponse::read(
|
||||
client_conn).await?;
|
||||
client_conn.handle_encryption_response(encryption_response)?;
|
||||
let server_id = client_conn.server_id_hash().await?;
|
||||
match multiplayer_auth::joined(&player.name, &server_id, None).await {
|
||||
Ok(_) => Ok(check_player_whitelist(player)),
|
||||
Err(_) =>
|
||||
Ok(PlayerAllowed::False(
|
||||
"Mojang Authentication Failed".to_string())),
|
||||
match proxy_info.authentication_method {
|
||||
listener::AuthenticationMethod::Mojang => {
|
||||
match multiplayer_auth::joined(
|
||||
&player.name, &server_id, None).await {
|
||||
Ok(_) => Ok(check_player_whitelist(player)),
|
||||
Err(_) => Ok(PlayerAllowed::False(
|
||||
"Mojang Authentication Failed".to_string()
|
||||
)),
|
||||
}},
|
||||
listener::AuthenticationMethod::None =>
|
||||
Ok(check_player_whitelist(player))
|
||||
}
|
||||
},
|
||||
listener::OnlineStatus::Offline =>
|
||||
|
|
|
@ -15,18 +15,20 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
let offline_info = listener::ProxyInfo{
|
||||
proxy_addr: "127.0.0.1".to_string(),
|
||||
proxy_port: 25565,
|
||||
online_status: listener::OnlineStatus::Offline,
|
||||
backend_addr: "127.0.0.1".to_string(),
|
||||
backend_port: 25564,
|
||||
private_key: private_key.clone(),
|
||||
online_status: listener::OnlineStatus::Offline,
|
||||
authentication_method: listener::AuthenticationMethod::None,
|
||||
};
|
||||
let online_info = listener::ProxyInfo{
|
||||
proxy_addr: "127.0.0.1".to_string(),
|
||||
proxy_port: 25566,
|
||||
online_status: listener::OnlineStatus::Online,
|
||||
backend_addr: "127.0.0.1".to_string(),
|
||||
backend_port: 25564,
|
||||
private_key: private_key.clone(),
|
||||
online_status: listener::OnlineStatus::Online,
|
||||
authentication_method: listener::AuthenticationMethod::Mojang,
|
||||
};
|
||||
|
||||
let listener_offline: listener::TcpListenerWrapper =
|
||||
|
|
Loading…
Reference in New Issue