Skip to content

Commit 8692e01

Browse files
committed
chore: cargo fmt
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 4ee2a18 commit 8692e01

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

host/src/bin/pyhl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ fn parse_mount(spec: &str) -> Result<Preopen> {
3939

4040
fn build_network_policy(net: bool, net_allow: &[String]) -> Result<Option<NetworkPolicy>> {
4141
if !net_allow.is_empty() {
42-
Ok(Some(NetworkPolicy::AllowList(AllowList::from_hosts(net_allow)?)))
42+
Ok(Some(NetworkPolicy::AllowList(AllowList::from_hosts(
43+
net_allow,
44+
)?)))
4345
} else if net {
4446
Ok(Some(NetworkPolicy::AllowAll))
4547
} else {

host/src/lib.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,7 @@ impl NetworkPolicy {
244244
if addr.port() == 53 || al.is_allowed(&addr.ip()) {
245245
Ok(())
246246
} else {
247-
Err(anyhow!(
248-
"network policy denies connection to {}",
249-
addr
250-
))
247+
Err(anyhow!("network policy denies connection to {}", addr))
251248
}
252249
}
253250
}
@@ -1923,12 +1920,7 @@ impl Sandbox {
19231920
initrd: Option<&Path>,
19241921
network: Option<&NetworkPolicy>,
19251922
) -> Result<Self> {
1926-
Self::from_snapshot_file_full(
1927-
path,
1928-
preopens,
1929-
initrd.map(|p| p.to_path_buf()),
1930-
network,
1931-
)
1923+
Self::from_snapshot_file_full(path, preopens, initrd.map(|p| p.to_path_buf()), network)
19321924
}
19331925

19341926
fn from_snapshot_file_full<P: AsRef<Path>>(
@@ -1992,8 +1984,15 @@ pub fn run_vm_with_tools(
19921984
config: VmConfig,
19931985
tools: ToolRegistry,
19941986
) -> Result<()> {
1995-
let _ =
1996-
Sandbox::evolve_inline(kernel_path, initrd, app_args, config, Some(tools), &[], None)?;
1987+
let _ = Sandbox::evolve_inline(
1988+
kernel_path,
1989+
initrd,
1990+
app_args,
1991+
config,
1992+
Some(tools),
1993+
&[],
1994+
None,
1995+
)?;
19971996
Ok(())
19981997
}
19991998

@@ -2459,8 +2458,7 @@ mod tests {
24592458
fn allowlist_resolves_hostnames() {
24602459
let al = AllowList::from_hosts(&["localhost"]).unwrap();
24612460
assert!(
2462-
al.is_allowed(&"127.0.0.1".parse().unwrap())
2463-
|| al.is_allowed(&"::1".parse().unwrap())
2461+
al.is_allowed(&"127.0.0.1".parse().unwrap()) || al.is_allowed(&"::1".parse().unwrap())
24642462
);
24652463
}
24662464

host/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ fn main() -> Result<()> {
164164
};
165165

166166
let network = if !args.net_allow.is_empty() {
167-
Some(NetworkPolicy::AllowList(AllowList::from_hosts(&args.net_allow)?))
167+
Some(NetworkPolicy::AllowList(AllowList::from_hosts(
168+
&args.net_allow,
169+
)?))
168170
} else if args.net {
169171
Some(NetworkPolicy::AllowAll)
170172
} else {

host/src/pyhl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ impl Runtime {
262262
} else {
263263
None
264264
};
265-
let sandbox =
266-
Sandbox::from_snapshot_file_configured(&snap, mounts, initrd_ref, network)?;
265+
let sandbox = Sandbox::from_snapshot_file_configured(&snap, mounts, initrd_ref, network)?;
267266
Ok(Self {
268267
sandbox,
269268
first_run: true,

0 commit comments

Comments
 (0)