[−][src]Struct pfctl::PfCtl
Struct communicating with the PF firewall.
Methods
impl PfCtl
[src]
pub fn new() -> Result<Self>
[src]
Returns a new PfCtl
if opening the PF device file succeeded.
pub fn enable(&mut self) -> Result<()>
[src]
Tries to enable PF. If the firewall is already enabled it will return an
StateAlreadyActive
error. If there is some other error it will return an IoctlError
.
pub fn try_enable(&mut self) -> Result<()>
[src]
Same as enable
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
pub fn disable(&mut self) -> Result<()>
[src]
Tries to disable PF. If the firewall is already disabled it will return an
StateAlreadyActive
error. If there is some other error it will return an IoctlError
.
pub fn try_disable(&mut self) -> Result<()>
[src]
Same as disable
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
pub fn is_enabled(&mut self) -> Result<bool>
[src]
Tries to determine if PF is enabled or not.
pub fn add_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
[src]
pub fn try_add_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
[src]
Same as add_anchor
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
pub fn remove_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
[src]
pub fn try_remove_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
[src]
Same as remove_anchor
, but AnchorDoesNotExist
errors are supressed and exchanged for
Ok(())
.
pub fn add_rule(&mut self, anchor: &str, rule: &FilterRule) -> Result<()>
[src]
pub fn set_rules(&mut self, anchor: &str, change: AnchorChange) -> Result<()>
[src]
pub fn add_redirect_rule(
&mut self,
anchor: &str,
rule: &RedirectRule
) -> Result<()>
[src]
&mut self,
anchor: &str,
rule: &RedirectRule
) -> Result<()>
pub fn flush_rules(&mut self, anchor: &str, kind: RulesetKind) -> Result<()>
[src]
pub fn clear_states(
&mut self,
anchor_name: &str,
kind: AnchorKind
) -> Result<u32>
[src]
&mut self,
anchor_name: &str,
kind: AnchorKind
) -> Result<u32>
Clear states created by rules in anchor. Returns total number of removed states upon success, otherwise ErrorKind::AnchorDoesNotExist if anchor does not exist.
Auto Trait Implementations
impl Send for PfCtl
impl Unpin for PfCtl
impl Sync for PfCtl
impl UnwindSafe for PfCtl
impl RefUnwindSafe for PfCtl
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,