pub struct PfCtl { /* private fields */ }
Expand description
Struct communicating with the PF firewall.
Implementations§
source§impl PfCtl
impl PfCtl
sourcepub fn enable(&mut self) -> Result<()>
pub fn enable(&mut self) -> Result<()>
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
.
sourcepub fn try_enable(&mut self) -> Result<()>
pub fn try_enable(&mut self) -> Result<()>
Same as enable
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
sourcepub fn disable(&mut self) -> Result<()>
pub fn disable(&mut self) -> Result<()>
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
.
sourcepub fn try_disable(&mut self) -> Result<()>
pub fn try_disable(&mut self) -> Result<()>
Same as disable
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
sourcepub fn is_enabled(&mut self) -> Result<bool>
pub fn is_enabled(&mut self) -> Result<bool>
Tries to determine if PF is enabled or not.
pub fn add_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
sourcepub fn try_add_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
pub fn try_add_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
Same as add_anchor
, but StateAlreadyActive
errors are supressed and exchanged for
Ok(())
.
pub fn remove_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
sourcepub fn try_remove_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
pub fn try_remove_anchor(&mut self, name: &str, kind: AnchorKind) -> Result<()>
Same as remove_anchor
, but AnchorDoesNotExist
errors are supressed and exchanged for
Ok(())
.
pub fn add_rule(&mut self, anchor: &str, rule: &FilterRule) -> Result<()>
pub fn set_rules(&mut self, anchor: &str, change: AnchorChange) -> Result<()>
pub fn add_redirect_rule( &mut self, anchor: &str, rule: &RedirectRule ) -> Result<()>
pub fn flush_rules(&mut self, anchor: &str, kind: RulesetKind) -> Result<()>
sourcepub fn clear_states(
&mut self,
anchor_name: &str,
kind: AnchorKind
) -> Result<u32>
pub fn clear_states( &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.
sourcepub fn clear_interface_states(&mut self, interface: Interface) -> Result<u32>
pub fn clear_interface_states(&mut self, interface: Interface) -> Result<u32>
Clear states belonging to a given interface Returns total number of removed states upon success