Skip to content

Commit b7e516d

Browse files
committed
remove codes again
1 parent 35b0fec commit b7e516d

File tree

14 files changed

+263
-442
lines changed

14 files changed

+263
-442
lines changed

Cargo.lock

Lines changed: 102 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ version = "2.4.1"
1616
anyhow = { version = "1.0" }
1717
bytes = "1"
1818
chrono = { version = "0.4" }
19-
clap = { version = "4.5.7"}
19+
clap = { version = "4.5"}
2020
console = "0.16"
2121
dashmap = "6.1"
2222
delay_timer = "0.11.6"
2323
duration-str = "0.17"
24-
flate2 = "1.0"
2524
futures = "0.3"
2625
futures-util = { version = "0.3", default-features = false }
2726
headers = "0.4"
@@ -30,8 +29,6 @@ if_chain = "1.0"
3029
indicatif = "0.18"
3130
lazy_static = "1.4"
3231
md-5 = "0.10"
33-
mime = "0.3"
34-
mime_guess = "2.0.0"
3532
percent-encoding = "2.1"
3633
regex = "1.10"
3734
reqwest = { version = "0.12", default-features = false }
@@ -46,4 +43,4 @@ tracing-core = "0.1.32"
4643
tracing-subscriber = { version = "0.3"}
4744
walkdir = "2.5"
4845
warp = "0.4.2"
49-
salvo = "0.84"
46+
salvo = "0.85.0"

config.toml

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,11 @@ addr = "0.0.0.0"
1919
## it would the port would be https.external_port(https.external_port should be defined), otherwise is false
2020
# redirect_https = true
2121

22-
# [https]
23-
# port = 443 # https bind address
24-
# addr = "0.0.0.0"
25-
## port when serving public network,default is https port. external_port should not be 0.
26-
# external_port = 443
2722

28-
## if set true, http server(80) will send client
29-
## status code:301(Moved Permanently) to tell client redirect to https
30-
31-
## default value for https ssl
32-
# [https.ssl]
33-
# private = "private.key path" # private ssl key
34-
# public = "public.cert path" # public ssl cert
35-
36-
## acme config, it doest not support run with https.ssl config.
37-
# [https.acme]
38-
## emails to Let's Encrypt needs to interact.
39-
# emails = ["mailto:[email protected]"]
40-
41-
## directory to store account and certificate
42-
## optional, default is ${file_dir}/acme
43-
# dir = "/data/acme"
4423

4524
## ci / stage / prod, default is prod, ci is just for CI test with Pebble, don't use it.
4625
# type = prod
4726

48-
## default cache config
49-
[cache]
50-
## if file size > max_size, it will not be cached. default is (10MB).
51-
# max_size = 10_000_000
52-
## gzip compression for js/json/icon/json, default is false,
53-
## only support gzip algo, and only compress cached files,
54-
## be careful to set it true
55-
# compression = false
56-
57-
## http header Cache-Control config,
58-
## optional, if not set, won't sender this header to client
59-
# [[cache.client_cache]]
60-
## 30day
61-
# expire = '30d'
62-
# extension_names = ['icon', 'gif', 'jpg', 'jpeg', 'png', 'js']
63-
# [[cache.client_cache]]
64-
# expire = '0'
65-
# extension_names = ['html']
66-
6727
## admin server config
6828
## admin server don't support hot reload. the config should not change.
6929
## optional, and it's disabled by default.
@@ -95,18 +55,3 @@ addr = "0.0.0.0"
9555
## optional, when https enabled, redirect_https default value true
9656
## it would the port would be https.external_port(https.external_port should be defined), otherwise is false
9757
# redirect_https = 443
98-
99-
## this would be usefully when set https.acme
100-
# disable_acme = false
101-
# [domains.https.ssl]
102-
103-
# [domains.cache]
104-
# max_size = 10_000_000
105-
# compression = false
106-
# [[domains.cache.client_cache]]
107-
# expire = '30d' # 30day
108-
# extension_names = ['icon', 'gif', 'jpg', 'jpeg', 'png', 'js']
109-
110-
111-
# [openTelemetry]
112-
# endpoint = "http://localhost:4317"

rustfmt.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

server/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ warp = { workspace = true, features = ["multipart", "server"] }
2929
# warp inner
3030
percent-encoding = { workspace = true }
3131
headers = { workspace = true }
32-
mime = { workspace = true }
33-
mime_guess = { workspace = true }
32+
3433
futures-util = { workspace = true }
35-
# gzip
36-
flate2 = { workspace = true }
34+
3735

3836
# tokio trace and log
3937
tracing = { workspace = true }

server/src/admin_server.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl AdminServer {
4444
.and(
4545
self.get_domain_info()
4646
.or(self.get_domain_upload_path())
47-
.or(self.get_files_metadata())
47+
.or(self.get_files_metadata()),
4848
)
4949
.or(warp::post().and(
5050
self.update_domain_version()
@@ -108,7 +108,6 @@ impl AdminServer {
108108
.and_then(service::update_domain_version)
109109
}
110110

111-
112111
fn change_upload_status(
113112
&self,
114113
) -> impl Filter<Extract = (impl warp::Reply,), Error = Rejection> + Clone {
@@ -282,7 +281,6 @@ pub mod service {
282281
}
283282
}
284283

285-
286284
pub(super) async fn change_upload_status(
287285
storage: Arc<DomainStorage>,
288286
param: UpdateUploadingStatusOption,
@@ -314,7 +312,6 @@ pub mod service {
314312
let mut resp = e.to_string().into_response();
315313
*resp.status_mut() = StatusCode::BAD_REQUEST;
316314

317-
318315
return Ok(resp);
319316
}
320317
let mut parts = form.into_stream();
@@ -371,8 +368,7 @@ pub mod service {
371368
for info in domains_info {
372369
let delete_versions = if let Some(max_reserve) = query.max_reserve {
373370
if let Some(mut max_version) =
374-
info.current_version
375-
.or(info.versions.iter().max().copied())
371+
info.current_version.or(info.versions.iter().max().copied())
376372
{
377373
//TODO: fix it, get reserve versions by array index compare, rather than -.
378374
max_version -= max_reserve;
@@ -418,7 +414,7 @@ pub mod service {
418414
Ok(_) => Response::default(),
419415
Err(e) => {
420416
let mut resp = e.to_string().into_response();
421-
* resp.status_mut() = StatusCode::BAD_REQUEST;
417+
*resp.status_mut() = StatusCode::BAD_REQUEST;
422418
resp
423419
}
424420
}

server/src/config.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ pub struct Config {
1616
pub admin_config: Option<AdminConfig>,
1717
pub http: HttpConfig,
1818
#[serde(default)]
19-
pub cache: CacheConfig,
20-
#[serde(default)]
2119
pub domains: Vec<DomainConfig>,
22-
pub open_telemetry: Option<OpenTelemetry>,
23-
}
24-
25-
#[derive(Deserialize, Debug, Clone, PartialEq)]
26-
pub struct OpenTelemetry {
27-
pub endpoint: String,
2820
}
2921

3022
//TODO: create config with lots of default value
@@ -69,7 +61,6 @@ fn default_max_upload_size() -> u64 {
6961
pub struct DomainConfig {
7062
pub domain: String,
7163
pub cors: Option<HashSet<OriginWrapper>>,
72-
pub cache: Option<DomainCacheConfig>,
7364
pub https: Option<DomainHttpsConfig>,
7465
pub alias: Option<Vec<String>>,
7566
pub redirect_https: Option<bool>,
@@ -97,8 +88,6 @@ pub enum ACMEType {
9788
Stage,
9889
}
9990

100-
101-
10291
#[derive(Deserialize, Debug, Clone, PartialEq)]
10392
pub struct HttpConfig {
10493
pub addr: String,
@@ -107,43 +96,13 @@ pub struct HttpConfig {
10796
pub redirect_https: Option<bool>,
10897
}
10998

110-
// should write Deserialize by hand.
111-
#[derive(Deserialize, Debug, Clone, PartialEq)]
112-
pub struct CacheConfig {
113-
#[serde(default = "default_max_size")]
114-
pub max_size: u64,
115-
#[serde(default)]
116-
pub compression: bool,
117-
#[serde(default)]
118-
pub client_cache: Vec<ClientCacheItem>,
119-
}
120-
#[derive(Deserialize, Debug, Clone, PartialEq)]
121-
pub struct DomainCacheConfig {
122-
pub max_size: Option<u64>,
123-
pub compression: Option<bool>,
124-
pub client_cache: Option<Vec<ClientCacheItem>>,
125-
}
126-
127-
fn default_max_size() -> u64 {
128-
10 * 1000 * 1000
129-
}
130-
13199
#[derive(Deserialize, Debug, Clone, PartialEq)]
132100
pub struct ClientCacheItem {
133101
#[serde(deserialize_with = "deserialize_duration")]
134102
pub expire: Duration,
135103
pub extension_names: Vec<String>,
136104
}
137105

138-
impl Default for CacheConfig {
139-
fn default() -> Self {
140-
CacheConfig {
141-
max_size: default_max_size(),
142-
client_cache: Vec::new(),
143-
compression: false,
144-
}
145-
}
146-
}
147106
#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
148107
pub struct DeprecatedVersionRemove {
149108
#[serde(default = "default_cron")]

server/src/cors.rs

Lines changed: 0 additions & 79 deletions
This file was deleted.

server/src/domain_storage.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,7 @@ impl DomainStorage {
629629
if !multiple.exists() {
630630
let parent = self.prefix.join(host);
631631
if !parent.exists() && fs::create_dir_all(&parent).is_err() {
632-
bail!(
633-
"create host directory {} failure",
634-
parent.display().to_string()
635-
)
632+
bail!("create host directory {} failure", parent.display())
636633
}
637634
if File::create_new(multiple).is_err() {
638635
bail!("files in same domain should not create at same time")
@@ -761,7 +758,6 @@ pub fn sanitize_path(base: impl AsRef<Path>, tail: &str) -> Result<PathBuf, Reje
761758
Ok(buf)
762759
}
763760

764-
765761
#[cfg(test)]
766762
mod test {
767763
use crate::config::Config;
@@ -848,7 +844,7 @@ mod test {
848844
.join("../tests/web/data")
849845
.display()
850846
.to_string();
851-
let file_cache = FileCache::new(&config);
847+
let file_cache = FileCache::new();
852848
let storage = DomainStorage::init(&config.file_dir, file_cache).unwrap();
853849
let result = storage.get_domain_info().unwrap();
854850

@@ -862,7 +858,6 @@ mod test {
862858
.read(true)
863859
.create(true)
864860
.append(true)
865-
866861
.open("/tmp/cde.txt")
867862
.unwrap();
868863
let mut text = String::new();

0 commit comments

Comments
 (0)