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