pub struct AccessControl { /* private fields */ }Expand description
ACL rules v2
ACL files are small ordered routing tables. They have one default action and a handful of explicit sections:
[default proxy]/[default direct]/[default block]- one line, specifies the default action[proxy_rules]- targets that must go through proxy[direct_rules]- targets that must connect directly[client_block]- client addresses that must be rejected by the server[outbound_block]/[block]- targets that must be blocked
Rule lines can be one of:
- CIDR network, like
10.9.0.32/16 - IP address, like
127.0.0.1or::1 - Exact domain, like
|google.com - Domain suffix, like
||google.com - Regular expression, like
(^|\.)gmail\.com$
Implementations§
Source§impl AccessControl
impl AccessControl
Sourcepub fn load_from_file<P: AsRef<Path>>(p: P) -> Result<AccessControl>
pub fn load_from_file<P: AsRef<Path>>(p: P) -> Result<AccessControl>
Load ACL rules from a file
Sourcepub fn is_ip_empty(&self) -> bool
pub fn is_ip_empty(&self) -> bool
Check if there are no IP routing rules.
Sourcepub fn is_host_empty(&self) -> bool
pub fn is_host_empty(&self) -> bool
Check if there are no host routing rules.
Sourcepub fn decide_host(&self, host: &str) -> Option<TargetDecision>
pub fn decide_host(&self, host: &str) -> Option<TargetDecision>
Decide how an ASCII domain should be handled.
Returns the first matching action, or None if no rule matches.
The caller can then fall back to the default action.
Sourcepub async fn decide_target(&self, addr: &Address) -> TargetDecision
pub async fn decide_target(&self, addr: &Address) -> TargetDecision
Decide how a target should be handled.
Sourcepub fn check_client_blocked(&self, addr: &SocketAddr) -> bool
pub fn check_client_blocked(&self, addr: &SocketAddr) -> bool
Check if client address should be blocked (for server)
Sourcepub async fn check_outbound_blocked(&self, outbound: &Address) -> bool
pub async fn check_outbound_blocked(&self, outbound: &Address) -> bool
Check if outbound address is blocked (for server)
NOTE: Address::DomainAddress is only validated by regex rules,
resolved addresses are checked in the lookup_outbound_then! macro
Trait Implementations§
Source§impl Clone for AccessControl
impl Clone for AccessControl
Source§fn clone(&self) -> AccessControl
fn clone(&self) -> AccessControl
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AccessControl
impl RefUnwindSafe for AccessControl
impl Send for AccessControl
impl Sync for AccessControl
impl Unpin for AccessControl
impl UnsafeUnpin for AccessControl
impl UnwindSafe for AccessControl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more