itsi-scheduler 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54e1eb45891e6c80746fd6792f4e0aebce2ac00f10fc59f3f2f0f11cc2361eea
4
- data.tar.gz: 663b7f505b1edf896f4bb3f73ad89407fe486dea0679181277bd242c55d0340d
3
+ metadata.gz: 24a6d189fe27eca28e684fa4093434a9970585fb51c3a80084153f10fbc62713
4
+ data.tar.gz: deba83cb54b75bacae1a0ebefa7dd12ec7b74385934fd72be6cdabae8093b96d
5
5
  SHA512:
6
- metadata.gz: bd15583060cfa4989fd876f8db9156230beabedfce76dad1ab333b4dd9657594fd341375ac0307df80653e7f05f52c204e793a2abea6091a2f763cc314c390a2
7
- data.tar.gz: 403ec39e2b91fc79da2bee12ef6cb8a86007299447ad752374adaad1243663bbc796ea0fe9150ff6efb878275277dded8aead5b15ff15df1ca787fe11977502f
6
+ metadata.gz: 6da8425690bfe5e5afa008a9a717abe2cd25ceb0729c916913eb2e4f84419ba83b72768d7021f909c43261fa5031d4d837c718e04eac1f8513a76f74f756d181
7
+ data.tar.gz: 14c2bcccf5f5b73590454b20ab2412064cf5b603d9fc10cdc32383a7693b2889a7bc46f62566cc694cee432ccf422287fa245d0dda629eeae80da10904e55038
data/Cargo.lock CHANGED
@@ -213,7 +213,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
213
213
 
214
214
  [[package]]
215
215
  name = "itsi-scheduler"
216
- version = "0.2.13"
216
+ version = "0.2.15"
217
217
  dependencies = [
218
218
  "bytes",
219
219
  "derive_more",
@@ -297,7 +297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
297
297
  checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
298
298
  dependencies = [
299
299
  "cfg-if",
300
- "windows-targets 0.48.5",
300
+ "windows-targets",
301
301
  ]
302
302
 
303
303
  [[package]]
@@ -443,7 +443,7 @@ dependencies = [
443
443
  "libc",
444
444
  "redox_syscall",
445
445
  "smallvec",
446
- "windows-targets 0.52.6",
446
+ "windows-targets",
447
447
  ]
448
448
 
449
449
  [[package]]
@@ -932,22 +932,7 @@ version = "0.52.0"
932
932
  source = "registry+https://github.com/rust-lang/crates.io-index"
933
933
  checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
934
934
  dependencies = [
935
- "windows-targets 0.52.6",
936
- ]
937
-
938
- [[package]]
939
- name = "windows-targets"
940
- version = "0.48.5"
941
- source = "registry+https://github.com/rust-lang/crates.io-index"
942
- checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
943
- dependencies = [
944
- "windows_aarch64_gnullvm 0.48.5",
945
- "windows_aarch64_msvc 0.48.5",
946
- "windows_i686_gnu 0.48.5",
947
- "windows_i686_msvc 0.48.5",
948
- "windows_x86_64_gnu 0.48.5",
949
- "windows_x86_64_gnullvm 0.48.5",
950
- "windows_x86_64_msvc 0.48.5",
935
+ "windows-targets",
951
936
  ]
952
937
 
953
938
  [[package]]
@@ -956,46 +941,28 @@ version = "0.52.6"
956
941
  source = "registry+https://github.com/rust-lang/crates.io-index"
957
942
  checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
958
943
  dependencies = [
959
- "windows_aarch64_gnullvm 0.52.6",
960
- "windows_aarch64_msvc 0.52.6",
961
- "windows_i686_gnu 0.52.6",
944
+ "windows_aarch64_gnullvm",
945
+ "windows_aarch64_msvc",
946
+ "windows_i686_gnu",
962
947
  "windows_i686_gnullvm",
963
- "windows_i686_msvc 0.52.6",
964
- "windows_x86_64_gnu 0.52.6",
965
- "windows_x86_64_gnullvm 0.52.6",
966
- "windows_x86_64_msvc 0.52.6",
948
+ "windows_i686_msvc",
949
+ "windows_x86_64_gnu",
950
+ "windows_x86_64_gnullvm",
951
+ "windows_x86_64_msvc",
967
952
  ]
968
953
 
969
- [[package]]
970
- name = "windows_aarch64_gnullvm"
971
- version = "0.48.5"
972
- source = "registry+https://github.com/rust-lang/crates.io-index"
973
- checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
974
-
975
954
  [[package]]
976
955
  name = "windows_aarch64_gnullvm"
977
956
  version = "0.52.6"
978
957
  source = "registry+https://github.com/rust-lang/crates.io-index"
979
958
  checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
980
959
 
981
- [[package]]
982
- name = "windows_aarch64_msvc"
983
- version = "0.48.5"
984
- source = "registry+https://github.com/rust-lang/crates.io-index"
985
- checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
986
-
987
960
  [[package]]
988
961
  name = "windows_aarch64_msvc"
989
962
  version = "0.52.6"
990
963
  source = "registry+https://github.com/rust-lang/crates.io-index"
991
964
  checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
992
965
 
993
- [[package]]
994
- name = "windows_i686_gnu"
995
- version = "0.48.5"
996
- source = "registry+https://github.com/rust-lang/crates.io-index"
997
- checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
998
-
999
966
  [[package]]
1000
967
  name = "windows_i686_gnu"
1001
968
  version = "0.52.6"
@@ -1008,48 +975,24 @@ version = "0.52.6"
1008
975
  source = "registry+https://github.com/rust-lang/crates.io-index"
1009
976
  checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
1010
977
 
1011
- [[package]]
1012
- name = "windows_i686_msvc"
1013
- version = "0.48.5"
1014
- source = "registry+https://github.com/rust-lang/crates.io-index"
1015
- checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
1016
-
1017
978
  [[package]]
1018
979
  name = "windows_i686_msvc"
1019
980
  version = "0.52.6"
1020
981
  source = "registry+https://github.com/rust-lang/crates.io-index"
1021
982
  checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
1022
983
 
1023
- [[package]]
1024
- name = "windows_x86_64_gnu"
1025
- version = "0.48.5"
1026
- source = "registry+https://github.com/rust-lang/crates.io-index"
1027
- checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
1028
-
1029
984
  [[package]]
1030
985
  name = "windows_x86_64_gnu"
1031
986
  version = "0.52.6"
1032
987
  source = "registry+https://github.com/rust-lang/crates.io-index"
1033
988
  checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
1034
989
 
1035
- [[package]]
1036
- name = "windows_x86_64_gnullvm"
1037
- version = "0.48.5"
1038
- source = "registry+https://github.com/rust-lang/crates.io-index"
1039
- checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
1040
-
1041
990
  [[package]]
1042
991
  name = "windows_x86_64_gnullvm"
1043
992
  version = "0.52.6"
1044
993
  source = "registry+https://github.com/rust-lang/crates.io-index"
1045
994
  checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
1046
995
 
1047
- [[package]]
1048
- name = "windows_x86_64_msvc"
1049
- version = "0.48.5"
1050
- source = "registry+https://github.com/rust-lang/crates.io-index"
1051
- checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
1052
-
1053
996
  [[package]]
1054
997
  name = "windows_x86_64_msvc"
1055
998
  version = "0.52.6"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-scheduler"
3
- version = "0.2.13"
3
+ version = "0.2.15"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -111,7 +111,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
111
111
 
112
112
  [[package]]
113
113
  name = "atty"
114
- version = "0.2.14"
114
+ version = "0.2.15"
115
115
  source = "registry+https://github.com/rust-lang/crates.io-index"
116
116
  checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
117
117
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-server"
3
- version = "0.2.13"
3
+ version = "0.2.15"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -43,7 +43,6 @@ itsi_tracing = { path = "../itsi_tracing" }
43
43
  itsi_acme = { path = "../itsi_acme" }
44
44
  jsonwebtoken = "9.3.1"
45
45
  magnus = { version = "0.7.1", features = ["bytes", "rb-sys"] }
46
- moka = { version = "0.12.10", features = ["sync"] }
47
46
  notify = { version = "8.0.0" }
48
47
  nix = { version = "0.29.0", features = [
49
48
  "socket",
@@ -55,6 +54,7 @@ nix = { version = "0.29.0", features = [
55
54
  num_cpus = "1.16.0"
56
55
  parking_lot = "0.12.3"
57
56
  pin-project = "1.1.9"
57
+ phf = { version = "0.11.3", features = ["macros"] }
58
58
  rand = "0.9.0"
59
59
  rcgen = { version = "0.13.2", features = ["x509-parser", "pem"] }
60
60
  regex = "1.11.1"
@@ -88,3 +88,5 @@ percent-encoding = "2.3.1"
88
88
  sha-crypt = "0.5.0"
89
89
  argon2 = "0.5.3"
90
90
  core_affinity = "0.8.3"
91
+ memchr = "2.7.4"
92
+ quick_cache = "0.6.13"
@@ -1,4 +1,4 @@
1
- use bytes::{Bytes, BytesMut};
1
+ use bytes::{Buf, Bytes, BytesMut};
2
2
  use derive_more::Debug;
3
3
  use futures::stream::{unfold, StreamExt};
4
4
  use http::{
@@ -12,6 +12,7 @@ use hyper_util::rt::TokioIo;
12
12
  use itsi_error::Result;
13
13
  use itsi_tracing::error;
14
14
  use magnus::error::Result as MagnusResult;
15
+ use memchr::{memchr, memchr_iter};
15
16
  use parking_lot::RwLock;
16
17
  use std::{
17
18
  collections::HashMap,
@@ -345,13 +346,54 @@ impl ItsiHttpResponse {
345
346
  let header_name: HeaderName = HeaderName::from_bytes(&name).map_err(|e| {
346
347
  itsi_error::ItsiError::InvalidInput(format!("Invalid header name {:?}: {:?}", name, e))
347
348
  })?;
348
- let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
349
349
  if let Some(ref mut resp) = *self.data.response.write() {
350
- resp.headers_mut().append(header_name, header_value);
350
+ let headers_mut = resp.headers_mut();
351
+ self.insert_header(headers_mut, &header_name, value);
351
352
  }
352
353
  Ok(())
353
354
  }
354
355
 
356
+ pub fn insert_header(
357
+ &self,
358
+ headers_mut: &mut HeaderMap,
359
+ header_name: &HeaderName,
360
+ value: Bytes,
361
+ ) {
362
+ static MAX_SPLIT_HEADERS: usize = 100;
363
+
364
+ let mut start = 0usize;
365
+ let mut emitted = 0usize;
366
+
367
+ for idx in memchr_iter(b'\n', &value).chain(std::iter::once(value.len())) {
368
+ if idx == start {
369
+ start += 1;
370
+ continue;
371
+ }
372
+
373
+ let mut part = value.slice(start..idx);
374
+ if part.ends_with(b"\r") {
375
+ part.truncate(part.len() - 1);
376
+ }
377
+ if let Some(&(b' ' | b'\t')) = part.first() {
378
+ part.advance(1);
379
+ }
380
+ if memchr(0, &part).is_some() || part.iter().any(|&b| b < 0x20) {
381
+ warn!("stripped control char from header {:?}", header_name);
382
+ start = idx + 1;
383
+ continue;
384
+ }
385
+
386
+ emitted += 1;
387
+ if emitted > MAX_SPLIT_HEADERS {
388
+ break;
389
+ }
390
+
391
+ let hv = unsafe { HeaderValue::from_maybe_shared_unchecked(part) };
392
+ headers_mut.append(header_name, hv);
393
+ start = idx + 1;
394
+ }
395
+ }
396
+
355
397
  pub fn add_headers(&self, headers: HashMap<Bytes, Vec<Bytes>>) -> MagnusResult<()> {
356
398
  if let Some(ref mut resp) = *self.data.response.write() {
357
399
  let headers_mut = resp.headers_mut();
@@ -363,8 +405,7 @@ impl ItsiHttpResponse {
363
405
  ))
364
406
  })?;
365
407
  for value in values {
366
- let header_value = unsafe { HeaderValue::from_maybe_shared_unchecked(value) };
367
- headers_mut.append(&header_name, header_value);
408
+ self.insert_header(headers_mut, &header_name, value);
368
409
  }
369
410
  }
370
411
  }
@@ -16,10 +16,15 @@ use http::{
16
16
  };
17
17
  use itsi_error::ItsiError;
18
18
  use magnus::error::Result;
19
- use moka::sync::Cache;
19
+ use quick_cache::sync::Cache;
20
20
  use regex::Regex;
21
21
  use serde::Deserialize;
22
- use std::{collections::HashMap, path::PathBuf, sync::OnceLock, time::Duration};
22
+ use std::{
23
+ collections::HashMap,
24
+ path::PathBuf,
25
+ sync::{Arc, OnceLock},
26
+ time::Duration,
27
+ };
23
28
  use tracing::debug;
24
29
 
25
30
  #[derive(Debug, Deserialize)]
@@ -76,10 +81,7 @@ impl MiddlewareLayer for StaticAssets {
76
81
  recheck_interval: Duration::from_secs(self.file_check_interval),
77
82
  serve_hidden_files: self.serve_hidden_files,
78
83
  allowed_extensions: self.allowed_extensions.clone(),
79
- miss_cache: Cache::builder()
80
- .max_capacity(self.max_files_in_memory)
81
- .time_to_live(Duration::from_secs(self.file_check_interval))
82
- .build(),
84
+ miss_cache: Arc::new(Cache::new(self.max_files_in_memory as usize)),
83
85
  })?)
84
86
  .map_err(ItsiError::new)?;
85
87
  Ok(())