itsi-server 0.2.21.rc2 → 0.2.21
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 +4 -4
- data/Cargo.lock +28 -1
- data/ext/itsi_acme/src/caches/no.rs +1 -1
- data/ext/itsi_acme/src/caches/test.rs +3 -3
- data/ext/itsi_acme/src/config.rs +6 -6
- data/ext/itsi_acme/src/lib.rs +1 -1
- data/ext/itsi_error/src/lib.rs +32 -15
- data/ext/itsi_rb_helpers/src/heap_value.rs +2 -2
- data/ext/itsi_scheduler/Cargo.toml +1 -1
- data/ext/itsi_scheduler/src/itsi_scheduler.rs +1 -1
- data/ext/itsi_server/Cargo.toml +1 -1
- data/ext/itsi_server/src/ruby_types/itsi_body_proxy/big_bytes.rs +10 -3
- data/ext/itsi_server/src/ruby_types/itsi_body_proxy/mod.rs +10 -6
- data/ext/itsi_server/src/ruby_types/itsi_grpc_call.rs +7 -5
- data/ext/itsi_server/src/ruby_types/itsi_grpc_response_stream/mod.rs +2 -2
- data/ext/itsi_server/src/ruby_types/itsi_http_request.rs +10 -7
- data/ext/itsi_server/src/ruby_types/itsi_http_response.rs +13 -5
- data/ext/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +6 -6
- data/ext/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +15 -11
- data/ext/itsi_server/src/ruby_types/itsi_server.rs +2 -2
- data/ext/itsi_server/src/server/middleware_stack/middleware.rs +1 -1
- data/ext/itsi_server/src/server/middleware_stack/middlewares/compression.rs +1 -3
- data/ext/itsi_server/src/server/middleware_stack/middlewares/mod.rs +2 -2
- data/ext/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +2 -2
- data/ext/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +1 -1
- data/ext/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +17 -7
- data/ext/itsi_server/src/server/middleware_stack/mod.rs +12 -12
- data/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +4 -3
- data/ext/itsi_server/src/services/password_hasher.rs +1 -1
- data/ext/itsi_server/src/services/static_file_server.rs +3 -4
- data/lib/itsi/server/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1bd2a908171b06331905949fa422899f9f1c104bc351cf18f64fa194e75d3a53
|
|
4
|
+
data.tar.gz: 75a9044dc44089edc2555ee72af7a61c51c50910c8845ae05e876bddc369d42b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35d0c81a040e5e182e210ebf0365775c0f8c8e277fa01942b491e43c4a6fee5efe28b48202c3925a6c3158bffe754403d4960ce66f00a7be415df73bc50549f7
|
|
7
|
+
data.tar.gz: fe30420266024df4a094d49b6cead529faa20a84b940fc6c99c095c5f3d7fd54fc77f103906d56919b7fa2588f65484e3c45c030bbb6467501565ba0a85525ad
|
data/Cargo.lock
CHANGED
|
@@ -1642,9 +1642,27 @@ version = "1.0.15"
|
|
|
1642
1642
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1643
1643
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
|
1644
1644
|
|
|
1645
|
+
[[package]]
|
|
1646
|
+
name = "itsi-scheduler"
|
|
1647
|
+
version = "0.2.21"
|
|
1648
|
+
dependencies = [
|
|
1649
|
+
"bytes",
|
|
1650
|
+
"derive_more",
|
|
1651
|
+
"itsi_error",
|
|
1652
|
+
"itsi_instrument_entry",
|
|
1653
|
+
"itsi_rb_helpers",
|
|
1654
|
+
"itsi_tracing",
|
|
1655
|
+
"magnus",
|
|
1656
|
+
"mio",
|
|
1657
|
+
"nix",
|
|
1658
|
+
"parking_lot",
|
|
1659
|
+
"rb-sys",
|
|
1660
|
+
"tracing",
|
|
1661
|
+
]
|
|
1662
|
+
|
|
1645
1663
|
[[package]]
|
|
1646
1664
|
name = "itsi-server"
|
|
1647
|
-
version = "0.2.21
|
|
1665
|
+
version = "0.2.21"
|
|
1648
1666
|
dependencies = [
|
|
1649
1667
|
"argon2",
|
|
1650
1668
|
"async-channel",
|
|
@@ -1754,6 +1772,15 @@ dependencies = [
|
|
|
1754
1772
|
"thiserror 2.0.12",
|
|
1755
1773
|
]
|
|
1756
1774
|
|
|
1775
|
+
[[package]]
|
|
1776
|
+
name = "itsi_instrument_entry"
|
|
1777
|
+
version = "0.1.0"
|
|
1778
|
+
dependencies = [
|
|
1779
|
+
"proc-macro2",
|
|
1780
|
+
"quote",
|
|
1781
|
+
"syn 1.0.109",
|
|
1782
|
+
]
|
|
1783
|
+
|
|
1757
1784
|
[[package]]
|
|
1758
1785
|
name = "itsi_rb_helpers"
|
|
1759
1786
|
version = "0.1.0"
|
|
@@ -7,7 +7,7 @@ use std::sync::atomic::AtomicPtr;
|
|
|
7
7
|
|
|
8
8
|
/// No-op cache, which does nothing.
|
|
9
9
|
/// ```rust
|
|
10
|
-
/// # use
|
|
10
|
+
/// # use itsi_acme::caches::NoCache;
|
|
11
11
|
/// # type EC = std::io::Error;
|
|
12
12
|
/// # type EA = EC;
|
|
13
13
|
/// let no_cache = NoCache::<EC, EA>::new();
|
|
@@ -10,9 +10,9 @@ use std::sync::atomic::AtomicPtr;
|
|
|
10
10
|
use std::sync::Arc;
|
|
11
11
|
|
|
12
12
|
/// Test cache, which generates certificates for ACME incompatible test environments.
|
|
13
|
-
/// ```rust
|
|
14
|
-
/// # use
|
|
15
|
-
/// # use
|
|
13
|
+
/// ```rust,no_run
|
|
14
|
+
/// # use itsi_acme::AcmeConfig;
|
|
15
|
+
/// # use itsi_acme::caches::{DirCache, TestCache};
|
|
16
16
|
/// # let test_environment = true;
|
|
17
17
|
/// let mut config = AcmeConfig::new(["example.com"])
|
|
18
18
|
/// .cache(DirCache::new("./cache"));
|
data/ext/itsi_acme/src/config.rs
CHANGED
|
@@ -31,9 +31,9 @@ impl AcmeConfig<Infallible, Infallible> {
|
|
|
31
31
|
/// error types will be `Infallible` since the cache cannot return an error. The methods to set
|
|
32
32
|
/// a cache will change the error types to match those returned by the supplied cache.
|
|
33
33
|
///
|
|
34
|
-
/// ```rust
|
|
35
|
-
/// # use
|
|
36
|
-
/// use
|
|
34
|
+
/// ```rust,no_run
|
|
35
|
+
/// # use itsi_acme::AcmeConfig;
|
|
36
|
+
/// use itsi_acme::caches::DirCache;
|
|
37
37
|
/// let config = AcmeConfig::new(["example.com"]).cache(DirCache::new("./rustls_acme_cache"));
|
|
38
38
|
/// ```
|
|
39
39
|
///
|
|
@@ -43,9 +43,9 @@ impl AcmeConfig<Infallible, Infallible> {
|
|
|
43
43
|
/// An uncached instance of [AcmeConfig] with particular type parameters can be created using
|
|
44
44
|
/// [NoCache].
|
|
45
45
|
///
|
|
46
|
-
/// ```rust
|
|
47
|
-
/// # use
|
|
48
|
-
/// use
|
|
46
|
+
/// ```rust,no_run
|
|
47
|
+
/// # use itsi_acme::AcmeConfig;
|
|
48
|
+
/// use itsi_acme::caches::NoCache;
|
|
49
49
|
/// # type EC = std::io::Error;
|
|
50
50
|
/// # type EA = EC;
|
|
51
51
|
/// let config: AcmeConfig<EC, EA> = AcmeConfig::new(["example.com"]).cache(NoCache::new());
|
data/ext/itsi_acme/src/lib.rs
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
//! ```rust,no_run
|
|
32
32
|
//! use tokio::io::AsyncWriteExt;
|
|
33
33
|
//! use futures::StreamExt;
|
|
34
|
-
//! use
|
|
34
|
+
//! use itsi_acme::{AcmeConfig, caches::DirCache};
|
|
35
35
|
//! use tokio_stream::wrappers::TcpListenerStream;
|
|
36
36
|
//!
|
|
37
37
|
//! #[tokio::main]
|
data/ext/itsi_error/src/lib.rs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
pub use anyhow::Context;
|
|
2
2
|
use magnus::Error as MagnusError;
|
|
3
|
-
use magnus::{
|
|
4
|
-
error::ErrorType,
|
|
5
|
-
exception::{self, arg_error, standard_error},
|
|
6
|
-
};
|
|
3
|
+
use magnus::{error::ErrorType, Ruby};
|
|
7
4
|
use thiserror::Error;
|
|
8
5
|
|
|
9
6
|
pub static CLIENT_CONNECTION_CLOSED: &str = "Client disconnected";
|
|
@@ -73,7 +70,10 @@ pub trait IntoMagnusError {
|
|
|
73
70
|
|
|
74
71
|
impl<T: std::error::Error> IntoMagnusError for T {
|
|
75
72
|
fn into_magnus_error(self) -> MagnusError {
|
|
76
|
-
MagnusError::new(
|
|
73
|
+
MagnusError::new(
|
|
74
|
+
Ruby::get().unwrap().exception_standard_error(),
|
|
75
|
+
self.to_string(),
|
|
76
|
+
)
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -92,17 +92,34 @@ impl From<String> for ItsiError {
|
|
|
92
92
|
impl From<ItsiError> for magnus::Error {
|
|
93
93
|
fn from(err: ItsiError) -> Self {
|
|
94
94
|
match err {
|
|
95
|
-
ItsiError::InvalidInput(msg) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
ItsiError::
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ItsiError::
|
|
102
|
-
magnus::Error::new(
|
|
95
|
+
ItsiError::InvalidInput(msg) => {
|
|
96
|
+
magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
|
|
97
|
+
}
|
|
98
|
+
ItsiError::InternalServerError(msg) => {
|
|
99
|
+
magnus::Error::new(Ruby::get().unwrap().exception_standard_error(), msg)
|
|
100
|
+
}
|
|
101
|
+
ItsiError::InternalError(msg) => {
|
|
102
|
+
magnus::Error::new(Ruby::get().unwrap().exception_standard_error(), msg)
|
|
103
|
+
}
|
|
104
|
+
ItsiError::UnsupportedProtocol(msg) => {
|
|
105
|
+
magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
|
|
106
|
+
}
|
|
107
|
+
ItsiError::ArgumentError(msg) => {
|
|
108
|
+
magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
|
|
109
|
+
}
|
|
110
|
+
ItsiError::Jump(msg) => {
|
|
111
|
+
magnus::Error::new(Ruby::get().unwrap().exception_local_jump_error(), msg)
|
|
112
|
+
}
|
|
113
|
+
ItsiError::ClientConnectionClosed => magnus::Error::new(
|
|
114
|
+
Ruby::get().unwrap().exception_eof_error(),
|
|
115
|
+
CLIENT_CONNECTION_CLOSED,
|
|
116
|
+
),
|
|
117
|
+
ItsiError::Break => {
|
|
118
|
+
magnus::Error::new(Ruby::get().unwrap().exception_interrupt(), "Break")
|
|
119
|
+
}
|
|
120
|
+
ItsiError::Pass => {
|
|
121
|
+
magnus::Error::new(Ruby::get().unwrap().exception_interrupt(), "Pass")
|
|
103
122
|
}
|
|
104
|
-
ItsiError::Break => magnus::Error::new(exception::interrupt(), "Break"),
|
|
105
|
-
ItsiError::Pass => magnus::Error::new(exception::interrupt(), "Pass"),
|
|
106
123
|
ItsiError::Io(err) => err.into_magnus_error(),
|
|
107
124
|
ItsiError::Rcgen(err) => err.into_magnus_error(),
|
|
108
125
|
ItsiError::HttpParse(err) => err.into_magnus_error(),
|
|
@@ -66,7 +66,7 @@ where
|
|
|
66
66
|
T: ReprValue,
|
|
67
67
|
{
|
|
68
68
|
fn into_value_with(self, _: &Ruby) -> Value {
|
|
69
|
-
self.0.
|
|
69
|
+
self.0.into_value_with(&magnus::Ruby::get().unwrap())
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -116,7 +116,7 @@ impl Deref for HeapVal {
|
|
|
116
116
|
|
|
117
117
|
impl IntoValue for HeapVal {
|
|
118
118
|
fn into_value_with(self, _: &Ruby) -> Value {
|
|
119
|
-
self.0.
|
|
119
|
+
self.0.into_value_with(&magnus::Ruby::get().unwrap())
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -68,7 +68,7 @@ impl ItsiScheduler {
|
|
|
68
68
|
pub fn wake(&self) -> MagnusResult<()> {
|
|
69
69
|
self.waker.lock().wake().map_err(|_| {
|
|
70
70
|
magnus::Error::new(
|
|
71
|
-
magnus::
|
|
71
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
72
72
|
"Failed to wake the scheduler",
|
|
73
73
|
)
|
|
74
74
|
})?;
|
data/ext/itsi_server/Cargo.toml
CHANGED
|
@@ -50,14 +50,21 @@ impl BigBytes {
|
|
|
50
50
|
if bytes.is_empty() {
|
|
51
51
|
None
|
|
52
52
|
} else {
|
|
53
|
-
Some(bytes.
|
|
53
|
+
Some(bytes.into_value_with(&magnus::Ruby::get().unwrap()))
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
BigBytes::OnDisk(path) => {
|
|
57
57
|
let ruby = Ruby::get().unwrap();
|
|
58
58
|
let rarray = ruby.ary_new();
|
|
59
|
-
rarray
|
|
60
|
-
|
|
59
|
+
rarray
|
|
60
|
+
.push(
|
|
61
|
+
path.path()
|
|
62
|
+
.to_str()
|
|
63
|
+
.unwrap()
|
|
64
|
+
.into_value_with(&magnus::Ruby::get().unwrap()),
|
|
65
|
+
)
|
|
66
|
+
.ok();
|
|
67
|
+
Some(rarray.into_value_with(&magnus::Ruby::get().unwrap()))
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -32,7 +32,9 @@ impl ItsiBody {
|
|
|
32
32
|
pub fn into_value(&self) -> Option<Value> {
|
|
33
33
|
match self {
|
|
34
34
|
ItsiBody::Buffered(bytes) => bytes.as_value(),
|
|
35
|
-
ItsiBody::Stream(proxy) =>
|
|
35
|
+
ItsiBody::Stream(proxy) => {
|
|
36
|
+
Some(proxy.clone().into_value_with(&magnus::Ruby::get().unwrap()))
|
|
37
|
+
}
|
|
36
38
|
ItsiBody::Empty => None,
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -54,7 +56,7 @@ impl ItsiBodyProxy {
|
|
|
54
56
|
if let Some(chunk) = block_on(stream.next()) {
|
|
55
57
|
let chunk = chunk.map_err(|err| {
|
|
56
58
|
magnus::Error::new(
|
|
57
|
-
magnus::
|
|
59
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
58
60
|
format!("Error reading body {:?}", err),
|
|
59
61
|
)
|
|
60
62
|
})?;
|
|
@@ -86,7 +88,7 @@ impl ItsiBodyProxy {
|
|
|
86
88
|
if let Some(chunk) = block_on(stream.next()) {
|
|
87
89
|
let chunk = chunk.map_err(|err| {
|
|
88
90
|
magnus::Error::new(
|
|
89
|
-
magnus::
|
|
91
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
90
92
|
format!("Error reading body {:?}", err),
|
|
91
93
|
)
|
|
92
94
|
})?;
|
|
@@ -97,7 +99,9 @@ impl ItsiBodyProxy {
|
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
let output_string = buffer
|
|
102
|
+
let output_string = buffer
|
|
103
|
+
.take()
|
|
104
|
+
.unwrap_or(magnus::Ruby::get().unwrap().str_buf_new(buf.len()));
|
|
101
105
|
output_string.cat(buf.clone());
|
|
102
106
|
buf.clear();
|
|
103
107
|
Ok(Some(output_string))
|
|
@@ -111,7 +115,7 @@ impl ItsiBodyProxy {
|
|
|
111
115
|
while let Some(chunk) = block_on(stream.next()) {
|
|
112
116
|
let chunk = chunk.map_err(|err| {
|
|
113
117
|
magnus::Error::new(
|
|
114
|
-
magnus::
|
|
118
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
115
119
|
format!("Error reading body {:?}", err),
|
|
116
120
|
)
|
|
117
121
|
})?;
|
|
@@ -133,7 +137,7 @@ impl ItsiBodyProxy {
|
|
|
133
137
|
fn verify_open(&self) -> MagnusResult<()> {
|
|
134
138
|
if self.closed.load(atomic::Ordering::SeqCst) {
|
|
135
139
|
return Err(magnus::Error::new(
|
|
136
|
-
magnus::
|
|
140
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
137
141
|
"Body stream is closed",
|
|
138
142
|
));
|
|
139
143
|
}
|
|
@@ -64,7 +64,9 @@ impl ItsiGrpcCall {
|
|
|
64
64
|
let snake_case_method_name = METHOD_NAME_REGEX
|
|
65
65
|
.replace_all(method_name, "${1}_${2}")
|
|
66
66
|
.to_lowercase();
|
|
67
|
-
Ok(
|
|
67
|
+
Ok(magnus::Ruby::get()
|
|
68
|
+
.unwrap()
|
|
69
|
+
.to_symbol(snake_case_method_name))
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
pub fn stream(&self) -> MagnusResult<ItsiGrpcResponseStream> {
|
|
@@ -205,7 +207,7 @@ impl ItsiGrpcCall {
|
|
|
205
207
|
})
|
|
206
208
|
.map_err(|e: std::io::Error| {
|
|
207
209
|
Error::new(
|
|
208
|
-
magnus::
|
|
210
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
209
211
|
format!("deflate decompression failed: {}", e),
|
|
210
212
|
)
|
|
211
213
|
})?;
|
|
@@ -224,7 +226,7 @@ impl ItsiGrpcCall {
|
|
|
224
226
|
})
|
|
225
227
|
.map_err(|e: std::io::Error| {
|
|
226
228
|
Error::new(
|
|
227
|
-
magnus::
|
|
229
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
228
230
|
format!("gzip decompression failed: {}", e),
|
|
229
231
|
)
|
|
230
232
|
})?;
|
|
@@ -243,7 +245,7 @@ impl ItsiGrpcCall {
|
|
|
243
245
|
})
|
|
244
246
|
.map_err(|e| {
|
|
245
247
|
Error::new(
|
|
246
|
-
magnus::
|
|
248
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
247
249
|
format!("gzip compression failed: {e}"),
|
|
248
250
|
)
|
|
249
251
|
})?;
|
|
@@ -262,7 +264,7 @@ impl ItsiGrpcCall {
|
|
|
262
264
|
})
|
|
263
265
|
.map_err(|e| {
|
|
264
266
|
Error::new(
|
|
265
|
-
magnus::
|
|
267
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
266
268
|
format!("deflate compression failed: {e}"),
|
|
267
269
|
)
|
|
268
270
|
})?;
|
|
@@ -59,7 +59,7 @@ impl ItsiGrpcResponseStreamInner {
|
|
|
59
59
|
.blocking_send(ByteFrame::Data(bytes))
|
|
60
60
|
.map_err(|err| {
|
|
61
61
|
magnus::Error::new(
|
|
62
|
-
magnus::
|
|
62
|
+
magnus::Ruby::get().unwrap().exception_io_error(),
|
|
63
63
|
format!("Trying to write to closed stream: {:?}", err),
|
|
64
64
|
)
|
|
65
65
|
})?;
|
|
@@ -80,7 +80,7 @@ impl ItsiGrpcResponseStreamInner {
|
|
|
80
80
|
let trailer_tx = std::mem::replace(&mut self.trailer_tx, oneshot::channel().0);
|
|
81
81
|
trailer_tx.send(header_map).map_err(|err| {
|
|
82
82
|
magnus::Error::new(
|
|
83
|
-
magnus::
|
|
83
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
84
84
|
format!("Error sending trailers {:?}", err),
|
|
85
85
|
)
|
|
86
86
|
})?;
|
|
@@ -6,9 +6,9 @@ use itsi_error::CLIENT_CONNECTION_CLOSED;
|
|
|
6
6
|
use itsi_rb_helpers::{funcall_no_ret, print_rb_backtrace, HeapValue};
|
|
7
7
|
use itsi_tracing::debug;
|
|
8
8
|
use magnus::{
|
|
9
|
-
block::
|
|
9
|
+
block::Proc,
|
|
10
10
|
error::{ErrorType, Result as MagnusResult},
|
|
11
|
-
Error, IntoValue, RHash,
|
|
11
|
+
Error, IntoValue, RHash,
|
|
12
12
|
};
|
|
13
13
|
use magnus::{
|
|
14
14
|
value::{LazyId, ReprValue},
|
|
@@ -110,20 +110,20 @@ impl ItsiHttpRequest {
|
|
|
110
110
|
// when building against Ruby < 3.2...
|
|
111
111
|
#[cfg(not(ruby_gte_3_2))]
|
|
112
112
|
{
|
|
113
|
-
|
|
113
|
+
magnus::Ruby::get().unwrap().hash_new()
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
for (i, group_name) in re.capture_names().enumerate().skip(1) {
|
|
117
117
|
if let Some(name) = group_name {
|
|
118
118
|
if let Some(m) = caps.get(i) {
|
|
119
119
|
// Insert into the hash: key is the group name, value is the match.
|
|
120
|
-
params.aset(
|
|
120
|
+
params.aset(magnus::Ruby::get().unwrap().to_symbol(name), m.as_str())?;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
Ok(params)
|
|
125
125
|
} else {
|
|
126
|
-
Ok(
|
|
126
|
+
Ok(magnus::Ruby::get().unwrap().hash_new())
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -201,7 +201,7 @@ impl ItsiHttpRequest {
|
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
203
|
Ok(_) => match receiver.await {
|
|
204
|
-
Ok(ResponseFrame::HttpResponse(response)) => Ok(response),
|
|
204
|
+
Ok(ResponseFrame::HttpResponse(response)) => Ok(*response),
|
|
205
205
|
Ok(ResponseFrame::HijackedResponse(response)) => {
|
|
206
206
|
match response.process_hijacked_response().await {
|
|
207
207
|
Ok(result) => Ok(result),
|
|
@@ -354,7 +354,10 @@ impl ItsiHttpRequest {
|
|
|
354
354
|
|
|
355
355
|
pub(crate) fn each_header(&self) -> MagnusResult<()> {
|
|
356
356
|
self.parts.headers.iter().for_each(|(hn, hv)| {
|
|
357
|
-
|
|
357
|
+
magnus::Ruby::get()
|
|
358
|
+
.unwrap()
|
|
359
|
+
.yield_values::<_, Value>((hn.as_str(), hv.to_str().unwrap_or("")))
|
|
360
|
+
.ok();
|
|
358
361
|
});
|
|
359
362
|
Ok(())
|
|
360
363
|
}
|
|
@@ -63,7 +63,7 @@ pub struct ResponseInner {
|
|
|
63
63
|
|
|
64
64
|
#[derive(Debug)]
|
|
65
65
|
pub enum ResponseFrame {
|
|
66
|
-
HttpResponse(HttpResponse),
|
|
66
|
+
HttpResponse(Box<HttpResponse>),
|
|
67
67
|
HijackedResponse(ItsiHttpResponse),
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -225,7 +225,9 @@ impl ItsiHttpResponse {
|
|
|
225
225
|
if let Some(mut response) = self.response.write().take() {
|
|
226
226
|
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
|
227
227
|
if let Some(sender) = self.response_sender.write().take() {
|
|
228
|
-
sender
|
|
228
|
+
sender
|
|
229
|
+
.send(ResponseFrame::HttpResponse(Box::new(response)))
|
|
230
|
+
.ok();
|
|
229
231
|
}
|
|
230
232
|
}
|
|
231
233
|
}
|
|
@@ -235,7 +237,9 @@ impl ItsiHttpResponse {
|
|
|
235
237
|
if let Some(mut response) = self.response.write().take() {
|
|
236
238
|
*response.status_mut() = StatusCode::SERVICE_UNAVAILABLE;
|
|
237
239
|
if let Some(sender) = self.response_sender.write().take() {
|
|
238
|
-
sender
|
|
240
|
+
sender
|
|
241
|
+
.send(ResponseFrame::HttpResponse(Box::new(response)))
|
|
242
|
+
.ok();
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
}
|
|
@@ -253,7 +257,9 @@ impl ItsiHttpResponse {
|
|
|
253
257
|
*response.body_mut() = HttpBody::stream(buffered);
|
|
254
258
|
self.frame_writer.write().replace(writer);
|
|
255
259
|
if let Some(sender) = self.response_sender.write().take() {
|
|
256
|
-
sender
|
|
260
|
+
sender
|
|
261
|
+
.send(ResponseFrame::HttpResponse(Box::new(response)))
|
|
262
|
+
.ok();
|
|
257
263
|
}
|
|
258
264
|
} else {
|
|
259
265
|
info!("No response!");
|
|
@@ -280,7 +286,9 @@ impl ItsiHttpResponse {
|
|
|
280
286
|
*response.body_mut() = HttpBody::full(frame);
|
|
281
287
|
}
|
|
282
288
|
if let Some(sender) = self.response_sender.write().take() {
|
|
283
|
-
sender
|
|
289
|
+
sender
|
|
290
|
+
.send(ResponseFrame::HttpResponse(Box::new(response)))
|
|
291
|
+
.ok();
|
|
284
292
|
}
|
|
285
293
|
}
|
|
286
294
|
|
|
@@ -110,7 +110,7 @@ pub fn send_watcher_command(fd: &OwnedFd, cmd: WatcherCommand) -> Result<()> {
|
|
|
110
110
|
match write(fd, &buf) {
|
|
111
111
|
Ok(_) => Ok(()),
|
|
112
112
|
Err(e) => Err(magnus::Error::new(
|
|
113
|
-
magnus::
|
|
113
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
114
114
|
format!("Failed to send command to watcher: {}", e),
|
|
115
115
|
)),
|
|
116
116
|
}
|
|
@@ -122,14 +122,14 @@ pub fn watch_groups(
|
|
|
122
122
|
// Create bidirectional pipes for communication
|
|
123
123
|
let (parent_read_fd, child_write_fd): (OwnedFd, OwnedFd) = pipe().map_err(|e| {
|
|
124
124
|
magnus::Error::new(
|
|
125
|
-
magnus::
|
|
125
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
126
126
|
format!("Failed to create parent read pipe: {}", e),
|
|
127
127
|
)
|
|
128
128
|
})?;
|
|
129
129
|
|
|
130
130
|
let (child_read_fd, parent_write_fd): (OwnedFd, OwnedFd) = pipe().map_err(|e| {
|
|
131
131
|
magnus::Error::new(
|
|
132
|
-
magnus::
|
|
132
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
133
133
|
format!("Failed to create child read pipe: {}", e),
|
|
134
134
|
)
|
|
135
135
|
})?;
|
|
@@ -137,7 +137,7 @@ pub fn watch_groups(
|
|
|
137
137
|
let fork_result = unsafe {
|
|
138
138
|
fork().map_err(|e| {
|
|
139
139
|
magnus::Error::new(
|
|
140
|
-
magnus::
|
|
140
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
141
141
|
format!("Failed to fork file watcher: {}", e),
|
|
142
142
|
)
|
|
143
143
|
})
|
|
@@ -194,7 +194,7 @@ pub fn watch_groups(
|
|
|
194
194
|
|
|
195
195
|
let glob = Glob::new(&remaining_pattern).map_err(|e| {
|
|
196
196
|
magnus::Error::new(
|
|
197
|
-
magnus::
|
|
197
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
198
198
|
format!(
|
|
199
199
|
"Failed to create watch glob for pattern '{}': {}",
|
|
200
200
|
remaining_pattern, e
|
|
@@ -203,7 +203,7 @@ pub fn watch_groups(
|
|
|
203
203
|
})?;
|
|
204
204
|
let glob_set = GlobSetBuilder::new().add(glob).build().map_err(|e| {
|
|
205
205
|
magnus::Error::new(
|
|
206
|
-
magnus::
|
|
206
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
207
207
|
format!("Failed to create watch glob set: {}", e),
|
|
208
208
|
)
|
|
209
209
|
})?;
|
|
@@ -14,7 +14,7 @@ use magnus::{
|
|
|
14
14
|
block::Proc,
|
|
15
15
|
error::Result,
|
|
16
16
|
value::{LazyId, ReprValue},
|
|
17
|
-
RArray, RHash, Ruby,
|
|
17
|
+
RArray, RHash, Ruby, TryConvert, Value,
|
|
18
18
|
};
|
|
19
19
|
use nix::{
|
|
20
20
|
fcntl::{fcntl, FcntlArg, FdFlag},
|
|
@@ -161,14 +161,14 @@ impl ServerParams {
|
|
|
161
161
|
Vec::<String>::try_convert(error_lines.unwrap().as_value())?;
|
|
162
162
|
ItsiServerConfig::print_config_errors(errors);
|
|
163
163
|
return Err(magnus::Error::new(
|
|
164
|
-
magnus::
|
|
164
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
165
165
|
"Failed to set middleware",
|
|
166
166
|
));
|
|
167
167
|
}
|
|
168
168
|
let middleware = MiddlewareSet::new(routes_raw)?;
|
|
169
169
|
self.middleware.set(middleware).map_err(|_| {
|
|
170
170
|
magnus::Error::new(
|
|
171
|
-
magnus::
|
|
171
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
172
172
|
"Failed to set middleware",
|
|
173
173
|
)
|
|
174
174
|
})?;
|
|
@@ -361,7 +361,7 @@ impl ServerParams {
|
|
|
361
361
|
let bind_to_fd_map: HashMap<String, i32> = serde_json::from_str(preexisting_listeners)
|
|
362
362
|
.map_err(|e| {
|
|
363
363
|
magnus::Error::new(
|
|
364
|
-
magnus::
|
|
364
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
365
365
|
format!("Invalid listener info: {}", e),
|
|
366
366
|
)
|
|
367
367
|
})?;
|
|
@@ -393,7 +393,10 @@ impl ServerParams {
|
|
|
393
393
|
.iter()
|
|
394
394
|
.map(|listener| {
|
|
395
395
|
listener.handover().map_err(|e| {
|
|
396
|
-
magnus::Error::new(
|
|
396
|
+
magnus::Error::new(
|
|
397
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
398
|
+
e.to_string(),
|
|
399
|
+
)
|
|
397
400
|
})
|
|
398
401
|
})
|
|
399
402
|
.collect::<Result<HashMap<String, i32>>>()?;
|
|
@@ -419,7 +422,8 @@ impl ItsiServerConfig {
|
|
|
419
422
|
itsi_config_proc.clone(),
|
|
420
423
|
) {
|
|
421
424
|
Ok(server_params) => {
|
|
422
|
-
cli_params
|
|
425
|
+
cli_params
|
|
426
|
+
.delete::<_, Value>(magnus::Ruby::get().unwrap().to_symbol("listeners"))?;
|
|
423
427
|
|
|
424
428
|
let watcher_fd = if let Some(watchers) = server_params.notify_watchers.clone() {
|
|
425
429
|
file_watcher::watch_groups(watchers)?
|
|
@@ -436,7 +440,7 @@ impl ItsiServerConfig {
|
|
|
436
440
|
})
|
|
437
441
|
}
|
|
438
442
|
Err(err) => Err(magnus::Error::new(
|
|
439
|
-
magnus::
|
|
443
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
440
444
|
format!("Error loading initial configuration {:?}", err),
|
|
441
445
|
)),
|
|
442
446
|
}
|
|
@@ -493,7 +497,7 @@ impl ItsiServerConfig {
|
|
|
493
497
|
if !errors.is_empty() {
|
|
494
498
|
Self::print_config_errors(errors);
|
|
495
499
|
return Err(magnus::Error::new(
|
|
496
|
-
magnus::
|
|
500
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
497
501
|
"Invalid server config",
|
|
498
502
|
));
|
|
499
503
|
}
|
|
@@ -567,13 +571,13 @@ impl ItsiServerConfig {
|
|
|
567
571
|
.map(|(str, fd)| {
|
|
568
572
|
let dupped_fd = dup(*fd).map_err(|errno| {
|
|
569
573
|
magnus::Error::new(
|
|
570
|
-
magnus::
|
|
574
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
571
575
|
format!("Errno {} while trying to dup {}", errno, fd),
|
|
572
576
|
)
|
|
573
577
|
})?;
|
|
574
578
|
Self::clear_cloexec(dupped_fd).map_err(|e| {
|
|
575
579
|
magnus::Error::new(
|
|
576
|
-
magnus::
|
|
580
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
577
581
|
format!("Failed to clear cloexec flag for fd {}: {}", dupped_fd, e),
|
|
578
582
|
)
|
|
579
583
|
})?;
|
|
@@ -629,7 +633,7 @@ impl ItsiServerConfig {
|
|
|
629
633
|
serde_json::to_string(&self.server_params.read().listener_info.lock().clone())
|
|
630
634
|
.map_err(|e| {
|
|
631
635
|
magnus::Error::new(
|
|
632
|
-
magnus::
|
|
636
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
633
637
|
format!("Invalid listener info: {}", e),
|
|
634
638
|
)
|
|
635
639
|
})?;
|
|
@@ -27,7 +27,7 @@ impl ItsiServer {
|
|
|
27
27
|
) -> Result<()> {
|
|
28
28
|
let ruby = Ruby::get().map_err(|_| {
|
|
29
29
|
magnus::Error::new(
|
|
30
|
-
magnus::
|
|
30
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
31
31
|
"Failed to acquire Ruby VM handle",
|
|
32
32
|
)
|
|
33
33
|
})?;
|
|
@@ -49,7 +49,7 @@ impl ItsiServer {
|
|
|
49
49
|
fn config(&self) -> Result<Arc<ItsiServerConfig>> {
|
|
50
50
|
self.config.lock().as_ref().cloned().ok_or_else(|| {
|
|
51
51
|
magnus::Error::new(
|
|
52
|
-
magnus::
|
|
52
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
53
53
|
"Itsi::Server not initialized",
|
|
54
54
|
)
|
|
55
55
|
})
|
|
@@ -293,9 +293,7 @@ impl MiddlewareLayer for Compression {
|
|
|
293
293
|
};
|
|
294
294
|
HttpBody::full(Bytes::from(compressed_bytes))
|
|
295
295
|
} else {
|
|
296
|
-
let stream = body
|
|
297
|
-
.into_data_stream()
|
|
298
|
-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e));
|
|
296
|
+
let stream = body.into_data_stream().map_err(std::io::Error::other);
|
|
299
297
|
let async_read_fut = StreamReader::new(stream);
|
|
300
298
|
let reader = BufReader::new(async_read_fut);
|
|
301
299
|
match compression_method {
|
|
@@ -43,9 +43,9 @@ pub use error_response::ErrorResponse;
|
|
|
43
43
|
pub use etag::ETag;
|
|
44
44
|
pub use intrusion_protection::IntrusionProtection;
|
|
45
45
|
pub use log_requests::LogRequests;
|
|
46
|
-
use magnus::{error::Result, Ruby};
|
|
47
46
|
use magnus::rb_sys::AsRawValue;
|
|
48
47
|
use magnus::Value;
|
|
48
|
+
use magnus::{error::Result, Ruby};
|
|
49
49
|
pub use max_body::MaxBody;
|
|
50
50
|
pub use proxy::Proxy;
|
|
51
51
|
pub use rate_limit::RateLimit;
|
|
@@ -90,7 +90,7 @@ pub trait FromValue: Sized + Send + Sync + 'static {
|
|
|
90
90
|
|
|
91
91
|
let ruby = Ruby::get().map_err(|_| {
|
|
92
92
|
magnus::Error::new(
|
|
93
|
-
magnus::
|
|
93
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
94
94
|
"Failed to acquire Ruby VM handle",
|
|
95
95
|
)
|
|
96
96
|
})?;
|
|
@@ -280,14 +280,14 @@ impl MiddlewareLayer for Proxy {
|
|
|
280
280
|
.build()
|
|
281
281
|
.map_err(|e| {
|
|
282
282
|
magnus::Error::new(
|
|
283
|
-
magnus::
|
|
283
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
284
284
|
format!("Failed to build Reqwest client: {}", e),
|
|
285
285
|
)
|
|
286
286
|
})?,
|
|
287
287
|
)
|
|
288
288
|
.map_err(|_e| {
|
|
289
289
|
magnus::Error::new(
|
|
290
|
-
magnus::
|
|
290
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
291
291
|
"Failed to save resolver backends",
|
|
292
292
|
)
|
|
293
293
|
})?;
|
|
@@ -42,7 +42,7 @@ impl Redirect {
|
|
|
42
42
|
*response.status_mut() = self.redirect_type.status_code();
|
|
43
43
|
let destination = self.to.rewrite_request(req, context).parse().map_err(|e| {
|
|
44
44
|
magnus::Error::new(
|
|
45
|
-
magnus::
|
|
45
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
46
46
|
format!("Invalid Rewrite String: {:?}: {}", self.to, e),
|
|
47
47
|
)
|
|
48
48
|
})?;
|
|
@@ -8,7 +8,7 @@ use async_trait::async_trait;
|
|
|
8
8
|
use derive_more::Debug;
|
|
9
9
|
use either::Either;
|
|
10
10
|
use itsi_rb_helpers::{HeapVal, HeapValue};
|
|
11
|
-
use magnus::{block::Proc, error::Result, value::ReprValue
|
|
11
|
+
use magnus::{block::Proc, error::Result, value::ReprValue};
|
|
12
12
|
use regex::Regex;
|
|
13
13
|
use std::str::FromStr;
|
|
14
14
|
use std::sync::atomic::Ordering;
|
|
@@ -44,23 +44,33 @@ impl FromStr for RequestType {
|
|
|
44
44
|
|
|
45
45
|
impl RubyApp {
|
|
46
46
|
pub fn from_value(params: HeapVal) -> magnus::error::Result<Arc<Self>> {
|
|
47
|
-
let app = params
|
|
47
|
+
let app = params
|
|
48
|
+
.funcall::<_, _, Proc>(magnus::Ruby::get().unwrap().to_symbol("[]"), ("app_proc",))?;
|
|
48
49
|
let sendfile = params
|
|
49
|
-
.funcall::<_, _, bool>(
|
|
50
|
+
.funcall::<_, _, bool>(magnus::Ruby::get().unwrap().to_symbol("[]"), ("sendfile",))
|
|
50
51
|
.unwrap_or(true);
|
|
51
52
|
let nonblocking = params
|
|
52
|
-
.funcall::<_, _, bool>(
|
|
53
|
+
.funcall::<_, _, bool>(
|
|
54
|
+
magnus::Ruby::get().unwrap().to_symbol("[]"),
|
|
55
|
+
("nonblocking",),
|
|
56
|
+
)
|
|
53
57
|
.unwrap_or(false);
|
|
54
58
|
let base_path_src = params
|
|
55
|
-
.funcall::<_, _, String>(
|
|
59
|
+
.funcall::<_, _, String>(magnus::Ruby::get().unwrap().to_symbol("[]"), ("base_path",))
|
|
56
60
|
.unwrap_or("".to_owned());
|
|
57
61
|
let script_name = params
|
|
58
|
-
.funcall::<_, _, Option<String>>(
|
|
62
|
+
.funcall::<_, _, Option<String>>(
|
|
63
|
+
magnus::Ruby::get().unwrap().to_symbol("[]"),
|
|
64
|
+
("script_name",),
|
|
65
|
+
)
|
|
59
66
|
.unwrap_or(None);
|
|
60
67
|
let base_path = Regex::new(&base_path_src).unwrap();
|
|
61
68
|
|
|
62
69
|
let request_type: RequestType = params
|
|
63
|
-
.funcall::<_, _, String>(
|
|
70
|
+
.funcall::<_, _, String>(
|
|
71
|
+
magnus::Ruby::get().unwrap().to_symbol("[]"),
|
|
72
|
+
("request_type",),
|
|
73
|
+
)
|
|
64
74
|
.unwrap_or("http".to_string())
|
|
65
75
|
.parse()
|
|
66
76
|
.unwrap_or(RequestType::Http);
|
|
@@ -49,7 +49,7 @@ impl StringMatch {
|
|
|
49
49
|
let src_str = value.funcall::<_, _, String>("source", ())?;
|
|
50
50
|
let regex = Regex::new(&src_str).map_err(|e| {
|
|
51
51
|
magnus::Error::new(
|
|
52
|
-
magnus::
|
|
52
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
53
53
|
format!("Invalid regexp: {}", e),
|
|
54
54
|
)
|
|
55
55
|
})?;
|
|
@@ -142,7 +142,7 @@ impl MiddlewareSet {
|
|
|
142
142
|
let mut routes = vec![];
|
|
143
143
|
for (index, route) in RArray::from_value(*routes_raw)
|
|
144
144
|
.ok_or(magnus::Error::new(
|
|
145
|
-
magnus::
|
|
145
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
146
146
|
format!("Routes must be an array. Got {:?}", routes_raw),
|
|
147
147
|
))?
|
|
148
148
|
.into_iter()
|
|
@@ -152,18 +152,18 @@ impl MiddlewareSet {
|
|
|
152
152
|
let route_raw = route_hash
|
|
153
153
|
.get("route")
|
|
154
154
|
.ok_or(magnus::Error::new(
|
|
155
|
-
magnus::
|
|
155
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
156
156
|
"Route is missing :route key",
|
|
157
157
|
))?
|
|
158
158
|
.funcall::<_, _, String>("source", ())?;
|
|
159
159
|
|
|
160
160
|
let middleware =
|
|
161
161
|
RHash::from_value(route_hash.get("middleware").ok_or(magnus::Error::new(
|
|
162
|
-
magnus::
|
|
162
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
163
163
|
"Route is missing middleware key",
|
|
164
164
|
))?)
|
|
165
165
|
.ok_or(magnus::Error::new(
|
|
166
|
-
magnus::
|
|
166
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
167
167
|
format!("middleware must be a hash. Got {:?}", routes_raw),
|
|
168
168
|
))?;
|
|
169
169
|
|
|
@@ -179,7 +179,7 @@ impl MiddlewareSet {
|
|
|
179
179
|
RArray::from_value(value)
|
|
180
180
|
.ok_or_else(|| {
|
|
181
181
|
magnus::Error::new(
|
|
182
|
-
magnus::
|
|
182
|
+
magnus::Ruby::get().unwrap().exception_type_error(),
|
|
183
183
|
"Expected array",
|
|
184
184
|
)
|
|
185
185
|
})
|
|
@@ -232,7 +232,7 @@ impl MiddlewareSet {
|
|
|
232
232
|
Ok(Self {
|
|
233
233
|
route_set: RegexSet::new(&routes).map_err(|e| {
|
|
234
234
|
magnus::Error::new(
|
|
235
|
-
magnus::
|
|
235
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
236
236
|
format!("Failed to create route set: {}", e),
|
|
237
237
|
)
|
|
238
238
|
})?,
|
|
@@ -243,7 +243,7 @@ impl MiddlewareSet {
|
|
|
243
243
|
.collect::<std::result::Result<Vec<Regex>, regex::Error>>()
|
|
244
244
|
.map_err(|e| {
|
|
245
245
|
magnus::Error::new(
|
|
246
|
-
magnus::
|
|
246
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
247
247
|
format!("Failed to create route set: {}", e),
|
|
248
248
|
)
|
|
249
249
|
})?
|
|
@@ -254,7 +254,7 @@ impl MiddlewareSet {
|
|
|
254
254
|
})
|
|
255
255
|
} else {
|
|
256
256
|
Err(magnus::Error::new(
|
|
257
|
-
magnus::
|
|
257
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
258
258
|
"Failed to create middleware stack",
|
|
259
259
|
))
|
|
260
260
|
}
|
|
@@ -286,7 +286,7 @@ impl MiddlewareSet {
|
|
|
286
286
|
self.route_set
|
|
287
287
|
);
|
|
288
288
|
Err(magnus::Error::new(
|
|
289
|
-
magnus::
|
|
289
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
290
290
|
format!(
|
|
291
291
|
"No matching middleware stack found for request: {:?}",
|
|
292
292
|
request
|
|
@@ -338,7 +338,7 @@ impl MiddlewareSet {
|
|
|
338
338
|
"app" => Ok(Middleware::RubyApp(RubyApp::from_value(parameters.into())?)),
|
|
339
339
|
"proxy" => Ok(Middleware::Proxy(Proxy::from_value(parameters)?)),
|
|
340
340
|
_ => Err(magnus::Error::new(
|
|
341
|
-
magnus::
|
|
341
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
342
342
|
format!("Unknown filter type: {}", mw_type),
|
|
343
343
|
)),
|
|
344
344
|
}
|
|
@@ -349,7 +349,7 @@ impl MiddlewareSet {
|
|
|
349
349
|
match result {
|
|
350
350
|
Ok(result) => Ok(result),
|
|
351
351
|
Err(err) => Err(magnus::Error::new(
|
|
352
|
-
magnus::
|
|
352
|
+
magnus::Ruby::get().unwrap().exception_standard_error(),
|
|
353
353
|
format!(
|
|
354
354
|
"Failed to instantiate middleware of type {}, due to {}",
|
|
355
355
|
middleware_type, err
|
|
@@ -145,9 +145,10 @@ impl ClusterMode {
|
|
|
145
145
|
|
|
146
146
|
call_with_gvl(|_| {
|
|
147
147
|
create_ruby_thread(move || {
|
|
148
|
-
call_without_gvl(move ||
|
|
149
|
-
Err(err)
|
|
150
|
-
|
|
148
|
+
call_without_gvl(move || {
|
|
149
|
+
if let Err(err) = worker_clone.boot(self_clone) {
|
|
150
|
+
error!("Worker boot failed {:?}", err);
|
|
151
|
+
}
|
|
151
152
|
})
|
|
152
153
|
});
|
|
153
154
|
});
|
|
@@ -28,7 +28,7 @@ pub enum HashAlgorithm {
|
|
|
28
28
|
pub fn create_password_hash(password: String, algo: Value) -> Result<String> {
|
|
29
29
|
let ruby = Ruby::get().map_err(|_| {
|
|
30
30
|
magnus::Error::new(
|
|
31
|
-
magnus::
|
|
31
|
+
magnus::Ruby::get().unwrap().exception_runtime_error(),
|
|
32
32
|
"Failed to acquire Ruby VM handle",
|
|
33
33
|
)
|
|
34
34
|
})?;
|
|
@@ -598,8 +598,7 @@ impl StaticFileServer {
|
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
if
|
|
602
|
-
let index_path = index_file.unwrap();
|
|
601
|
+
if let Some(index_path) = index_file {
|
|
603
602
|
self.key_to_path
|
|
604
603
|
.lock()
|
|
605
604
|
.insert(key.to_string(), index_path.clone());
|
|
@@ -1254,8 +1253,8 @@ async fn generate_directory_listing(
|
|
|
1254
1253
|
});
|
|
1255
1254
|
|
|
1256
1255
|
// Serialize the JSON object to a pretty-printed string.
|
|
1257
|
-
let json_string =
|
|
1258
|
-
.map_err(
|
|
1256
|
+
let json_string =
|
|
1257
|
+
serde_json::to_string_pretty(&json_obj).map_err(std::io::Error::other)?;
|
|
1259
1258
|
|
|
1260
1259
|
Ok(json_string)
|
|
1261
1260
|
}
|
data/lib/itsi/server/version.rb
CHANGED