|
4 | 4 |
|
5 | 5 | use crate::{ |
6 | 6 | config::{OsType, Provisioner, VmConfig}, |
7 | | - tests::config_nym::BOOTSTRAP_SCRIPT, |
| 7 | + tests::config_nym::{ |
| 8 | + BOOTSTRAP_SCRIPT, DELAYED_IP_BLOCK_SCRIPT, IP_BLOCK_SCRIPT, SNI_BLOCK_SCRIPT, |
| 9 | + }, |
8 | 10 | }; |
9 | 11 | use anyhow::{Context, Result, bail}; |
10 | 12 | use ssh2::{File, Session}; |
@@ -150,17 +152,19 @@ fn blocking_ssh( |
150 | 152 | ssh_send_file_with_opts(&session, &source, temp_dir, FileOpts { executable: true }) |
151 | 153 | .with_context(|| format!("Failed to send '{source:?}' to remote"))?; |
152 | 154 |
|
153 | | - // Transfer blocking scripts |
| 155 | + // Transfer blocking scripts. Their contents are baked into this binary via include_bytes!, |
| 156 | + // so we write them to the guest directly rather than reading them off the host filesystem. |
154 | 157 | if matches!(os_type, OsType::Linux | OsType::Macos) { |
155 | | - let blocking_scripts_dir = |
156 | | - Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../scripts/blocking")); |
157 | | - let scripts = ["ip_block.sh", "sni_block.sh", "delayed_ip_block.sh"]; |
158 | | - |
159 | | - for script in &scripts { |
160 | | - let source = blocking_scripts_dir.join(script); |
161 | | - log::debug!("Source: {}", source.display()); |
162 | | - ssh_send_file_with_opts(&session, &source, temp_dir, FileOpts { executable: true }) |
163 | | - .with_context(|| format!("Failed to send blocking script '{script}' to remote"))?; |
| 158 | + let scripts: [(&str, &[u8]); 3] = [ |
| 159 | + ("ip_block.sh", IP_BLOCK_SCRIPT), |
| 160 | + ("sni_block.sh", SNI_BLOCK_SCRIPT), |
| 161 | + ("delayed_ip_block.sh", DELAYED_IP_BLOCK_SCRIPT), |
| 162 | + ]; |
| 163 | + |
| 164 | + for (name, content) in &scripts { |
| 165 | + let dest = temp_dir.join(name); |
| 166 | + ssh_write_with_opts(&session, &dest, *content, FileOpts { executable: true }) |
| 167 | + .with_context(|| format!("Failed to send blocking script '{name}' to remote"))?; |
164 | 168 | } |
165 | 169 | } |
166 | 170 |
|
|
0 commit comments