diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-25 21:01:02 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-25 21:01:02 +0100 |
commit | 75ab384426ceaef0ef9c117cd180e4c52a5e8f96 (patch) | |
tree | 9a5a17347f40b45644fdeefc70cbdfd808eddfd0 | |
parent | 4f4f54ec239df336ca4ecc0cae9126452a2f707c (diff) | |
download | jellything-75ab384426ceaef0ef9c117cd180e4c52a5e8f96.tar jellything-75ab384426ceaef0ef9c117cd180e4c52a5e8f96.tar.bz2 jellything-75ab384426ceaef0ef9c117cd180e4c52a5e8f96.tar.zst |
debug asset tokens
-rw-r--r-- | base/src/assetfed.rs | 3 | ||||
-rw-r--r-- | base/src/cache.rs | 3 | ||||
-rw-r--r-- | server/src/routes/api/mod.rs | 10 | ||||
-rw-r--r-- | server/src/routes/mod.rs | 6 |
4 files changed, 16 insertions, 6 deletions
diff --git a/base/src/assetfed.rs b/base/src/assetfed.rs index 0eff59f..e7c0124 100644 --- a/base/src/assetfed.rs +++ b/base/src/assetfed.rs @@ -8,6 +8,7 @@ use base64::Engine; use bincode::{Decode, Encode}; use jellycommon::Asset; use log::warn; +use serde::Serialize; use std::{path::PathBuf, sync::LazyLock}; const VERSION: u32 = 3; @@ -25,7 +26,7 @@ static ASSET_KEY: LazyLock<Aes256GcmSiv> = LazyLock::new(|| { } }); -#[derive(Debug, Encode, Decode)] +#[derive(Debug, Encode, Decode, Serialize)] pub enum AssetInner { Federated { host: String, asset: Vec<u8> }, Cache(CachePath), diff --git a/base/src/cache.rs b/base/src/cache.rs index f42df84..5e47d0e 100644 --- a/base/src/cache.rs +++ b/base/src/cache.rs @@ -9,6 +9,7 @@ use base64::Engine; use bincode::{Decode, Encode}; use log::{info, warn}; use rand::random; +use serde::Serialize; use std::{ any::Any, collections::{BTreeMap, HashMap}, @@ -27,7 +28,7 @@ use tokio::{ sync::Mutex, }; -#[derive(Debug, Encode, Decode)] +#[derive(Debug, Encode, Decode, Serialize)] pub struct CachePath(pub PathBuf); impl CachePath { pub fn abs(&self) -> PathBuf { diff --git a/server/src/routes/api/mod.rs b/server/src/routes/api/mod.rs index 7166273..025653b 100644 --- a/server/src/routes/api/mod.rs +++ b/server/src/routes/api/mod.rs @@ -9,7 +9,10 @@ use super::ui::{ }; use crate::database::DataAcid; use anyhow::{anyhow, Context}; -use jellybase::database::{TableExt, T_NODE}; +use jellybase::{ + assetfed::AssetInner, + database::{TableExt, T_NODE}, +}; use jellycommon::{user::CreateSessionParams, Node}; use rocket::{ get, @@ -62,6 +65,11 @@ pub fn r_api_node_raw( .ok_or(anyhow!("node does not exist"))?; Ok(Json(node)) } +#[get("/api/asset_token_raw/<token>")] +pub fn r_api_asset_token_raw(admin: AdminSession, token: &str) -> MyResult<Json<AssetInner>> { + drop(admin); + Ok(Json(AssetInner::deser(token)?)) +} pub struct AcceptJson(bool); impl Deref for AcceptJson { diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index ced786b..27fb4f7 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -3,8 +3,9 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin <metamuffin.org> */ +use self::playersync::{r_streamsync, PlayersyncChannels}; use crate::{database::DataAcid, routes::ui::error::MyResult}; -use api::{r_api_account_login, r_api_node_raw, r_api_root, r_api_version}; +use api::{r_api_account_login, r_api_asset_token_raw, r_api_node_raw, r_api_root, r_api_version}; use base64::Engine; use jellybase::{federation::Federation, CONF, SECRETS}; use log::warn; @@ -44,8 +45,6 @@ use ui::{ }; use userdata::{r_node_userdata, r_player_progress, r_player_watched}; -use self::playersync::{r_streamsync, PlayersyncChannels}; - pub mod api; pub mod playersync; pub mod stream; @@ -137,6 +136,7 @@ pub fn build_rocket(database: DataAcid, federation: Federation) -> Rocket<Build> r_api_account_login, r_api_root, r_api_node_raw, + r_api_asset_token_raw, ], ) } |