-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
243 additions
and
191 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
pub mod status; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use leptos::*; | ||
use minecraft_msa_auth::MinecraftAuthorizationFlow; | ||
use minecraft_msa_auth::MinecraftAccessToken; | ||
use oauth2::basic::BasicClient; | ||
use oauth2::reqwest::async_http_client; | ||
use oauth2::{ | ||
AuthType, AuthUrl, AuthorizationCode, ClientId, CsrfToken, PkceCodeChallenge, RedirectUrl, Scope, TokenResponse, | ||
TokenUrl, ClientSecret | ||
}; | ||
|
||
|
||
|
||
#[component] | ||
pub fn Login() -> View { | ||
view! { | ||
<div> | ||
<h1> | ||
Login | ||
</h1> | ||
</div> | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod login; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod server_status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use leptos::*; | ||
|
||
#[cfg(feature = "ssr")] | ||
use craftping::tokio::ping; | ||
#[cfg(feature = "ssr")] | ||
use tokio::net::TcpStream; | ||
|
||
use atb_types::McServerStatus; | ||
|
||
#[server(McServerStatusInternalLeptosName, "/api", "GetJson", "ping_mc_server")] | ||
pub async fn ping_minecraft_server() -> Result<McServerStatus, ServerFnError> { | ||
// todo : extract out to a variable for configurability | ||
let hostname = "mc.arun.gg"; | ||
let port = 25565; | ||
let mut stream = TcpStream::connect((hostname, port)).await?; | ||
|
||
let pong: craftping::Response = ping(&mut stream, hostname, port).await?; | ||
|
||
let sample = match pong.sample { | ||
None => vec![], | ||
Some(s) => s | ||
.into_iter() | ||
.map(|craftping::Player { name, id }| (name, id)) | ||
.collect::<Vec<_>>(), | ||
}; | ||
|
||
let favicon = pong.favicon.unwrap_or(vec![]); | ||
|
||
let res = McServerStatus { | ||
version: pong.version, | ||
max_players: pong.max_players, | ||
online_players: pong.online_players, | ||
sample, | ||
favicon, | ||
}; | ||
|
||
Ok(res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.