mirror of
https://github.com/cirruslabs/softnet.git
synced 2026-09-29 19:41:10 +02:00
Added a way to enable host-only networking through tart using --net-host (#32)
* Added a way to enable host-only networking through tart using SOFTNET_NET_TYPE=host * Removed env variable and moved to Enum instead of str * Fixed defaults & restricted publicity of host * Fixed usage of NetType
This commit is contained in:
+5
-1
@@ -2,6 +2,7 @@ use anyhow::{anyhow, Context};
|
||||
use clap::Parser;
|
||||
use nix::sys::signal::{signal, SigHandler, Signal};
|
||||
use privdrop::PrivDrop;
|
||||
use softnet::NetType;
|
||||
use softnet::proxy::Proxy;
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
@@ -28,6 +29,9 @@ struct Args {
|
||||
#[clap(long, help = "MAC address to enforce for the VM")]
|
||||
vm_mac_address: mac_address::MacAddress,
|
||||
|
||||
#[clap(long, arg_enum, help = "type of network to use for the VM", default_value_t=NetType::Nat)]
|
||||
vm_net_type: NetType,
|
||||
|
||||
#[clap(
|
||||
long,
|
||||
help = "set bootpd(8) lease time to this value (in seconds) before starting the VM",
|
||||
@@ -140,7 +144,7 @@ fn try_main() -> anyhow::Result<()> {
|
||||
set_bootpd_lease_time(args.bootpd_lease_time);
|
||||
|
||||
// Initialize the proxy while still having the root privileges
|
||||
let mut proxy = Proxy::new(args.vm_fd as RawFd, args.vm_mac_address)
|
||||
let mut proxy = Proxy::new(args.vm_fd as RawFd, args.vm_mac_address, args.vm_net_type)
|
||||
.context("failed to initialize proxy")?;
|
||||
|
||||
// Drop effective privileges to the user
|
||||
|
||||
Reference in New Issue
Block a user