Struct tun2proxy::Args

source ·
pub struct Args {
Show 16 fields pub proxy: ArgProxy, pub tun: Option<String>, pub tun_fd: Option<i32>, pub close_fd_on_drop: Option<bool>, pub unshare: bool, pub unshare_pidfile: Option<String>, pub socket_transfer_fd: Option<i32>, pub admin_command: Vec<OsString>, pub ipv6_enabled: bool, pub setup: bool, pub dns: ArgDns, pub dns_addr: IpAddr, pub bypass: Vec<IpCidr>, pub tcp_timeout: u64, pub udp_timeout: u64, pub verbosity: ArgVerbosity,
}

Fields§

§proxy: ArgProxy

Proxy URL in the form proto://[username[:password]@]host:port, where proto is one of socks4, socks5, http. Username and password are encoded in percent encoding. For example: socks5://myname:pass%40word@127.0.0.1:1080

§tun: Option<String>

Name of the tun interface, such as tun0, utun4, etc. If this option is not provided, the OS will generate a random one.

§tun_fd: Option<i32>

File descriptor of the tun interface

§close_fd_on_drop: Option<bool>

Set whether to close the received raw file descriptor on drop or not. This setting is passed to the tun2 crate. See tun2::Configuration::close_fd_on_drop.

§unshare: bool

Create a tun interface in a newly created unprivileged namespace while maintaining proxy connectivity via the global network namespace.

§unshare_pidfile: Option<String>

Create a pidfile of unshare process when using --unshare.

§socket_transfer_fd: Option<i32>

File descriptor for UNIX datagram socket meant to transfer network sockets from global namespace to the new one. See unshare(1), namespaces(7), sendmsg(2), unix(7).

§admin_command: Vec<OsString>

Specify a command to run with root-like capabilities in the new namespace when using --unshare. This could be useful to start additional daemons, e.g. openvpn instance.

§ipv6_enabled: bool

IPv6 enabled

§setup: bool

Routing and system setup, which decides whether to setup the routing and system configuration. This option is only available on Linux and requires root-like privileges. See capabilities(7).

§dns: ArgDns

DNS handling strategy

§dns_addr: IpAddr

DNS resolver address

§bypass: Vec<IpCidr>

IPs used in routing setup which should bypass the tunnel, in the form of IP or IP/CIDR. Multiple IPs can be specified, e.g. –bypass 3.4.5.0/24 –bypass 5.6.7.8

§tcp_timeout: u64

TCP timeout in seconds

§udp_timeout: u64

UDP timeout in seconds

§verbosity: ArgVerbosity

Verbosity level

Implementations§

source§

impl Args

source

pub fn parse_args() -> Self

source

pub fn proxy(&mut self, proxy: ArgProxy) -> &mut Self

source

pub fn dns(&mut self, dns: ArgDns) -> &mut Self

source

pub fn tun_fd(&mut self, tun_fd: Option<i32>) -> &mut Self

source

pub fn close_fd_on_drop(&mut self, close_fd_on_drop: bool) -> &mut Self

source

pub fn verbosity(&mut self, verbosity: ArgVerbosity) -> &mut Self

source

pub fn tun(&mut self, tun: String) -> &mut Self

source

pub fn dns_addr(&mut self, dns_addr: IpAddr) -> &mut Self

source

pub fn bypass(&mut self, bypass: IpCidr) -> &mut Self

source

pub fn ipv6_enabled(&mut self, ipv6_enabled: bool) -> &mut Self

source

pub fn setup(&mut self, setup: bool) -> &mut Self

Trait Implementations§

source§

impl Args for Args

source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self. Read more
source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can update self. Read more
source§

impl Clone for Args

source§

fn clone(&self) -> Args

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CommandFactory for Args

source§

fn command<'b>() -> Command

Build a Command that can instantiate Self. Read more
source§

fn command_for_update<'b>() -> Command

Build a Command that can update self. Read more
source§

impl Debug for Args

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Args

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl FromArgMatches for Args

source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

impl Parser for Args

source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error.
source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error.
source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error.
source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

§

impl Freeze for Args

§

impl RefUnwindSafe for Args

§

impl Send for Args

§

impl Sync for Args

§

impl Unpin for Args

§

impl UnwindSafe for Args

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

fn type_name(&self) -> &'static str

Gets the type name of self
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more