TunInterfaceOptions -> TunOptions

This commit is contained in:
dav 2023-06-28 12:23:33 -07:00 committed by David Zhong
parent f20f56062c
commit d3882bd008
6 changed files with 13 additions and 13 deletions

View file

@ -9,4 +9,4 @@ pub(crate) mod imp;
mod options;
pub use imp::{TunInterface, TunQueue};
pub use options::TunInterfaceOptions;
pub use options::TunOptions;

View file

@ -4,7 +4,7 @@ use std::io::Error;
use super::TunInterface;
#[derive(Default)]
pub struct TunInterfaceOptions {
pub struct TunOptions {
/// (Windows + Linux) Name the tun interface.
pub(crate) name: Option<String>,
/// (Linux) Don't include packet information.
@ -13,7 +13,7 @@ pub struct TunInterfaceOptions {
pub(crate) tun_excl: Option<()>,
}
impl TunInterfaceOptions {
impl TunOptions {
pub fn new() -> Self {
Self::default()
}

View file

@ -15,7 +15,7 @@ mod sys;
pub use super::queue::TunQueue;
use super::{ifname_to_string, string_to_ifname, TunInterfaceOptions};
use super::{ifname_to_string, string_to_ifname, TunOptions};
use kern_control::SysControlSocket;
#[derive(Debug)]
@ -26,11 +26,11 @@ pub struct TunInterface {
impl TunInterface {
#[throws]
pub fn new() -> TunInterface {
Self::new_with_options(TunInterfaceOptions::new())?
Self::new_with_options(TunOptions::new())?
}
#[throws]
pub fn new_with_options(_: TunInterfaceOptions) -> TunInterface {
pub fn new_with_options(_: TunOptions) -> TunInterface {
TunInterface::connect(0)?
}

View file

@ -12,7 +12,7 @@ use log::info;
use libc::in6_ifreq;
use super::{ifname_to_string, string_to_ifname, TunInterfaceOptions};
use super::{ifname_to_string, string_to_ifname, TunOptions};
mod sys;
@ -24,11 +24,11 @@ pub struct TunInterface {
impl TunInterface {
#[throws]
pub fn new() -> TunInterface {
Self::new_with_options(TunInterfaceOptions::new())?
Self::new_with_options(TunOptions::new())?
}
#[throws]
pub(crate) fn new_with_options(options: TunInterfaceOptions) -> TunInterface {
pub(crate) fn new_with_options(options: TunOptions) -> TunInterface {
let file = OpenOptions::new()
.read(true)
.write(true)

View file

@ -3,7 +3,7 @@ use std::{
os::fd::{AsRawFd, FromRawFd, IntoRawFd, RawFd},
};
use super::TunInterfaceOptions;
use super::TunOptions;
mod queue;

View file

@ -5,7 +5,7 @@ use widestring::U16CString;
use windows::Win32::Foundation::GetLastError;
mod queue;
use super::TunInterfaceOptions;
use super::TunOptions;
pub use queue::TunQueue;
@ -17,11 +17,11 @@ pub struct TunInterface {
impl TunInterface {
#[throws]
pub fn new() -> TunInterface {
Self::new_with_options(TunInterfaceOptions::new())?
Self::new_with_options(TunOptions::new())?
}
#[throws]
pub(crate) fn new_with_options(options: TunInterfaceOptions) -> TunInterface {
pub(crate) fn new_with_options(options: TunOptions) -> TunInterface {
let name_owned = options.name.unwrap_or("Burrow".to_owned());
let name = U16CString::from_str(&name_owned).unwrap();