pub struct FirewallRule {
pub role: Role,
pub protocol: Protocol,
pub port: u16,
pub destination: Option<String>,
pub sources: Vec<String>,
pub reason: String,
}Expand description
One inbound admission the mesh needs on this host: a protocol and a port, the group it is
addressed to when it is multicast, the networks it may come from, and the sentence that
says why. A rule is derived, never written by hand; FirewallRule::label is how a
verdict names it.
use majordomus_cli::mesh::firewall::{FirewallRule, Protocol, Role};
let rule = FirewallRule {
role: Role::Hub,
protocol: Protocol::Tcp,
port: 8791,
destination: None,
sources: vec!["192.168.7.0/24".into()],
reason: "this machine is a declared rendezvous hub".into(),
};
assert_eq!(rule.label(), "tcp/8791 from 192.168.7.0/24");Fields§
§role: RoleWhy.
protocol: ProtocolThe transport protocol.
port: u16The destination port.
destination: Option<String>The destination address when it is a multicast group; None for this host’s own.
sources: Vec<String>The networks the traffic may come from, as CIDR; empty admits any source, which is only ever the case for the multicast group, whose TTL keeps it on the segment.
reason: StringThe sentence a person reads beside the rule.
Implementations§
Source§impl FirewallRule
impl FirewallRule
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
tcp/8791 from 192.168.7.0/24, 100.64.0.0/10 — one line for a verdict: the
protocol and port, the group when there is one, and the sources or any.
use majordomus_cli::mesh::firewall::{FirewallRule, Protocol, Role};
let group = FirewallRule {
role: Role::Multicast,
protocol: Protocol::Udp,
port: 7741,
destination: Some("239.255.77.77".into()),
sources: vec![],
reason: String::new(),
};
assert_eq!(group.label(), "udp/7741 to 239.255.77.77 from any");Trait Implementations§
Source§impl Clone for FirewallRule
impl Clone for FirewallRule
Source§fn clone(&self) -> FirewallRule
fn clone(&self) -> FirewallRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FirewallRule
impl Debug for FirewallRule
Source§impl<'de> Deserialize<'de> for FirewallRule
impl<'de> Deserialize<'de> for FirewallRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for FirewallRule
Source§impl JsonSchema for FirewallRule
impl JsonSchema for FirewallRule
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for FirewallRule
impl PartialEq for FirewallRule
Source§fn eq(&self, other: &FirewallRule) -> bool
fn eq(&self, other: &FirewallRule) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for FirewallRule
impl Serialize for FirewallRule
impl StructuralPartialEq for FirewallRule
Auto Trait Implementations§
impl Freeze for FirewallRule
impl RefUnwindSafe for FirewallRule
impl Send for FirewallRule
impl Sync for FirewallRule
impl Unpin for FirewallRule
impl UnsafeUnpin for FirewallRule
impl UnwindSafe for FirewallRule
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.