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