进行一个夹带私货
This commit is contained in:
parent
26addf3fb1
commit
be814a0614
@ -106,7 +106,7 @@ mod tests {
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct TestConfig {
|
||||
pub cluster_port: u32,
|
||||
pub cluster_port: Option<u32>,
|
||||
pub cluster_id: String,
|
||||
pub cluster_secret: String,
|
||||
}
|
||||
@ -118,7 +118,7 @@ mod tests {
|
||||
|
||||
Config::new(
|
||||
None,
|
||||
"".to_string(),
|
||||
None,
|
||||
test_conf.cluster_port,
|
||||
test_conf.cluster_id,
|
||||
test_conf.cluster_secret,
|
||||
|
@ -2,6 +2,7 @@ use {
|
||||
crate::fatal,
|
||||
log::{error, info, warn},
|
||||
std::{env, fs},
|
||||
serde::{Serialize, Deserialize}
|
||||
};
|
||||
|
||||
const CONFIG_PATH: &str = "config.toml";
|
||||
@ -97,12 +98,6 @@ impl Config {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Self> {
|
||||
toml::from_str(&self.load_raw()?).map_err(|err| {
|
||||
fatal!("Failed to parse config file");
|
||||
})
|
||||
}
|
||||
|
||||
pub fn join_center_url(&self, path: &str) -> String {
|
||||
format!("{}{}", self.center_url, path)
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ impl IntoResponse for MeasureRes {
|
||||
///
|
||||
/// export default MeasureRoute
|
||||
/// ```
|
||||
///
|
||||
pub async fn measure(header: HeaderMap, Path(size): Path<u32>) -> MeasureRes {
|
||||
let mut data: Vec<u8> = Vec::new();
|
||||
match header.get("x-openbmclapi-secret") {
|
||||
Some(secret) => {
|
||||
if secret != "secret" {
|
||||
@ -55,10 +55,9 @@ pub async fn measure(header: HeaderMap, Path(size): Path<u32>) -> MeasureRes {
|
||||
if size > 200 {
|
||||
return MeasureRes::BadResquest;
|
||||
}
|
||||
let buffer: Vec<u8> = vec![0x00, 0x66, 0xcc, 0xff];
|
||||
for _ in 0..size {
|
||||
data.extend(&buffer);
|
||||
}
|
||||
// size -> size * mb
|
||||
let mut data: Vec<u8> = Vec::with_capacity((size * 1024 * 1024) as usize);
|
||||
data.fill(114_u8);
|
||||
return MeasureRes::Data(data);
|
||||
}
|
||||
None => MeasureRes::Forbidden
|
||||
|
Loading…
Reference in New Issue
Block a user