pub struct DockerNatBackend { /* private fields */ }Expand description
Manages Docker resources for NAT simulation
Implementations§
Source§impl DockerNatBackend
impl DockerNatBackend
Sourcepub async fn new(config: DockerNatConfig) -> Result<Self>
pub async fn new(config: DockerNatConfig) -> Result<Self>
Create a new Docker NAT backend
Sourcepub async fn create_public_network(&mut self) -> Result<String>
pub async fn create_public_network(&mut self) -> Result<String>
Create the public network where gateways live
If the initially chosen subnet conflicts with an existing Docker network, this will retry with a different random subnet up to MAX_SUBNET_RETRIES times.
Sourcepub async fn create_nat_network(
&mut self,
peer_index: usize,
) -> Result<(String, String, Ipv4Addr)>
pub async fn create_nat_network( &mut self, peer_index: usize, ) -> Result<(String, String, Ipv4Addr)>
Create a private network behind NAT for a peer
Sourcepub async fn ensure_base_image(&self) -> Result<String>
pub async fn ensure_base_image(&self) -> Result<String>
Build the base Freenet peer Docker image
Sourcepub async fn copy_binary_to_container(
&self,
container_id: &str,
binary_path: &Path,
) -> Result<()>
pub async fn copy_binary_to_container( &self, container_id: &str, binary_path: &Path, ) -> Result<()>
Copy binary into a container
Sourcepub async fn create_gateway(
&mut self,
index: usize,
binary_path: &Path,
keypair_path: &Path,
public_key_path: &Path,
ws_port: u16,
network_port: u16,
run_root: &Path,
) -> Result<(DockerPeerInfo, DockerProcess)>
pub async fn create_gateway( &mut self, index: usize, binary_path: &Path, keypair_path: &Path, public_key_path: &Path, ws_port: u16, network_port: u16, run_root: &Path, ) -> Result<(DockerPeerInfo, DockerProcess)>
Create a gateway container (on public network, no NAT)
Sourcepub async fn create_peer(
&mut self,
index: usize,
binary_path: &Path,
keypair_path: &Path,
public_key_path: &Path,
gateways_toml_path: &Path,
gateway_public_key_path: Option<&Path>,
ws_port: u16,
network_port: u16,
run_root: &Path,
) -> Result<(DockerPeerInfo, DockerProcess)>
pub async fn create_peer( &mut self, index: usize, binary_path: &Path, keypair_path: &Path, public_key_path: &Path, gateways_toml_path: &Path, gateway_public_key_path: Option<&Path>, ws_port: u16, network_port: u16, run_root: &Path, ) -> Result<(DockerPeerInfo, DockerProcess)>
Create a peer container behind NAT
Sourcepub async fn copy_file_to_container_pub(
&self,
container_id: &str,
local_path: &Path,
container_path: &str,
) -> Result<()>
pub async fn copy_file_to_container_pub( &self, container_id: &str, local_path: &Path, container_path: &str, ) -> Result<()>
Copy a file into a container (public version)
Sourcepub async fn cleanup(&mut self) -> Result<()>
pub async fn cleanup(&mut self) -> Result<()>
Clean up all Docker resources created by this backend
Sourcepub fn get_peer_info(&self, index: usize) -> Option<&DockerPeerInfo>
pub fn get_peer_info(&self, index: usize) -> Option<&DockerPeerInfo>
Get peer info by index
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DockerNatBackend
impl !RefUnwindSafe for DockerNatBackend
impl Send for DockerNatBackend
impl Sync for DockerNatBackend
impl Unpin for DockerNatBackend
impl !UnwindSafe for DockerNatBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more