Skip to content

Commit 2614ff9

Browse files
committed
Merge branch 'WIN-54-http-body-filter' into win-47-file-filter
2 parents 336691a + 7b7460a commit 2614ff9

File tree

6 files changed

+42
-11
lines changed

6 files changed

+42
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mirrord/cli/src/ci.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{
22
collections::HashMap,
33
env::{self, temp_dir},
44
fs::File,
5-
os::unix::process::ExitStatusExt,
65
path::{Path, PathBuf},
76
process::Stdio,
87
time::SystemTime,
@@ -15,6 +14,8 @@ use mirrord_auth::credentials::CiApiKey;
1514
use mirrord_config::{LayerConfig, ci::CiConfig, config::ConfigContext};
1615
use mirrord_operator::client::OperatorApi;
1716
use mirrord_progress::{Progress, ProgressTracker};
17+
#[cfg(not(target_os = "windows"))]
18+
use os::unix::process::ExitStatusExt;
1819
use rand::distr::{Alphanumeric, SampleString};
1920
use serde::{Deserialize, Serialize};
2021
use tokio::{
@@ -209,7 +210,8 @@ impl MirrordCi {
209210
/// Very similar to to how `mirrord exec` behaves, except that here we `spawn` a child process
210211
/// that'll keep running, and we store the pid of this process in [`MirrordCiStore`] so we can
211212
/// kill it later.
212-
#[cfg_attr(target_os = "windows", allow(unused))]
213+
// #[cfg_attr(target_os = "windows", allow(unused))]
214+
#[cfg(not(target_os = "windows"))]
213215
#[tracing::instrument(level = Level::TRACE, skip(progress), err)]
214216
pub(super) async fn prepare_command<P: Progress>(
215217
self,

mirrord/cli/src/ci/stop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use tracing::Level;
22

33
use super::CiResult;
4-
use crate::MirrordCiStore;
4+
use crate::ci::MirrordCiStore;
55
#[cfg(not(target_os = "windows"))]
66
use crate::ci::error::CiError;
77

mirrord/layer-lib/src/setup/windows.rs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use mirrord_config::{
99
NetworkConfig,
1010
incoming::{
1111
IncomingConfig, IncomingMode as ConfigIncomingMode,
12-
http_filter::{HttpFilterConfig, InnerFilter, PortList},
12+
http_filter::{BodyFilter, HttpFilterConfig, InnerFilter},
1313
},
1414
outgoing::OutgoingConfig,
1515
},
@@ -18,7 +18,7 @@ use mirrord_config::{
1818
use mirrord_intproxy_protocol::PortSubscription;
1919
use mirrord_protocol::{
2020
Port,
21-
tcp::{Filter, HttpFilter, HttpMethodFilter, MirrorType, StealType},
21+
tcp::{Filter, HttpBodyFilter, HttpFilter, HttpMethodFilter, MirrorType, StealType},
2222
};
2323

2424
use crate::{
@@ -213,9 +213,10 @@ impl IncomingMode {
213213
let ports = config
214214
.http_filter
215215
.ports
216-
.as_ref()
217-
.map(|port_list| port_list.iter().copied().collect())
218-
.unwrap_or(PortList::default().into());
216+
.get_or_insert_default()
217+
.iter()
218+
.copied()
219+
.collect();
219220

220221
let filter = Self::parse_http_filter(&config.http_filter);
221222

@@ -228,12 +229,23 @@ impl IncomingMode {
228229
}
229230
}
230231

232+
fn parse_body_filter(filter: &BodyFilter) -> HttpBodyFilter {
233+
match filter {
234+
BodyFilter::Json { query, matches } => HttpBodyFilter::Json {
235+
query: query.clone(),
236+
matches: Filter::new(matches.clone())
237+
.expect("invalid json body filter `matches` string"),
238+
},
239+
}
240+
}
241+
231242
fn parse_http_filter(http_filter_config: &HttpFilterConfig) -> HttpFilter {
232243
match http_filter_config {
233244
HttpFilterConfig {
234245
path_filter: Some(path),
235246
header_filter: None,
236247
method_filter: None,
248+
body_filter: None,
237249
all_of: None,
238250
any_of: None,
239251
ports: _ports,
@@ -243,6 +255,7 @@ impl IncomingMode {
243255
path_filter: None,
244256
header_filter: Some(header),
245257
method_filter: None,
258+
body_filter: None,
246259
all_of: None,
247260
any_of: None,
248261
ports: _ports,
@@ -252,6 +265,7 @@ impl IncomingMode {
252265
path_filter: None,
253266
header_filter: None,
254267
method_filter: Some(method),
268+
body_filter: None,
255269
all_of: None,
256270
any_of: None,
257271
ports: _ports,
@@ -263,6 +277,17 @@ impl IncomingMode {
263277
path_filter: None,
264278
header_filter: None,
265279
method_filter: None,
280+
body_filter: Some(filter),
281+
all_of: None,
282+
any_of: None,
283+
ports: _ports,
284+
} => HttpFilter::Body(Self::parse_body_filter(filter)),
285+
286+
HttpFilterConfig {
287+
path_filter: None,
288+
header_filter: None,
289+
method_filter: None,
290+
body_filter: None,
266291
all_of: Some(filters),
267292
any_of: None,
268293
ports: _ports,
@@ -272,6 +297,7 @@ impl IncomingMode {
272297
path_filter: None,
273298
header_filter: None,
274299
method_filter: None,
300+
body_filter: None,
275301
all_of: None,
276302
any_of: Some(filters),
277303
ports: _ports,
@@ -294,6 +320,9 @@ impl IncomingMode {
294320
InnerFilter::Method { method } => HttpFilter::Method(
295321
HttpMethodFilter::from_str(method).expect("invalid method filter string"),
296322
),
323+
InnerFilter::Body(body_filter) => {
324+
HttpFilter::Body(Self::parse_body_filter(body_filter))
325+
}
297326
})
298327
.collect();
299328

mirrord/layer-lib/src/socket/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::os::unix::io::RawFd;
33
use std::{
44
convert::TryFrom,
5-
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
5+
net::{Ipv4Addr, Ipv6Addr, SocketAddr},
66
sync::Arc,
77
};
88

mirrord/protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mirrord-protocol"
3-
version = "1.23.0"
3+
version = "1.23.1"
44
authors.workspace = true
55
description.workspace = true
66
documentation.workspace = true

0 commit comments

Comments
 (0)