-
Notifications
You must be signed in to change notification settings - Fork 3
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
21 changed files
with
640 additions
and
130 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,6 +5,11 @@ authors = ["Xiphoseer <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
assembly-core = { git = "https://github.com/Xiphoseer/assembly_rs.git" } | ||
assembly-maps = { git = "https://github.com/Xiphoseer/assembly_rs.git" } | ||
assembly-pack = { git = "https://github.com/Xiphoseer/assembly_rs.git" } | ||
assembly-fdb = { git = "https://github.com/Xiphoseer/assembly_rs.git", default-features = false, features = ["serde-derives"] } | ||
assembly-xml = { git = "https://github.com/Xiphoseer/assembly_rs.git" } | ||
base64 = "0.13" | ||
handlebars = "3.5" | ||
pretty_env_logger = "0.4.0" | ||
|
@@ -27,14 +32,6 @@ version = "0.3" | |
features = ["tls", "multipart"] | ||
default-features = false | ||
|
||
[dependencies.assembly-core] | ||
version = "0.2.1" | ||
|
||
[dependencies.assembly-data] | ||
version = "0.3.0" | ||
default-features = false | ||
features = ["serde-derives"] | ||
|
||
# Holds data in insertion order | ||
[dependencies.linked-hash-map] | ||
version = "0.5.3" | ||
|
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,47 @@ | ||
use assembly_pack::pki::core::PackFileRef; | ||
use color_eyre::eyre::Context; | ||
use serde::Serialize; | ||
use std::{path::Path, sync::Arc}; | ||
use tracing::error; | ||
|
||
use warp::{ | ||
filters::BoxedFilter, | ||
hyper::StatusCode, | ||
reply::{json, with_status, Json, WithStatus}, | ||
Filter, | ||
}; | ||
|
||
use crate::data::fs::{Loader, Node}; | ||
|
||
#[derive(Serialize)] | ||
struct CRCReply<'a> { | ||
fs: Option<&'a Node>, | ||
pk: Option<&'a PackFileRef>, | ||
} | ||
|
||
/// Lookup information on a CRC i.e. a file path in the client | ||
pub fn make_crc_lookup_filter( | ||
res_path: &Path, | ||
pki_path: Option<&Path>, | ||
) -> BoxedFilter<(WithStatus<Json>,)> { | ||
let mut loader = Loader::new(); | ||
loader.load_dir(Path::new("client/res"), res_path); | ||
if let Some(pki_path) = pki_path { | ||
if let Err(e) = loader | ||
.load_pki(pki_path) | ||
.with_context(|| format!("Failed to load PKI file at '{}'", pki_path.display())) | ||
{ | ||
error!("{}", e); | ||
} | ||
} | ||
|
||
let loader = Arc::new(loader); | ||
|
||
warp::path::param() | ||
.map(move |crc: u32| { | ||
let fs = loader.get(crc).map(|e| &e.public); | ||
let pk = loader.get_pki(crc); | ||
with_status(json(&CRCReply { fs, pk }), StatusCode::OK) | ||
}) | ||
.boxed() | ||
} |
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
Oops, something went wrong.