Fix subnets validation
This commit is contained in:
+20
@@ -46,10 +46,29 @@ pub struct ClientDisplay {
|
||||
pub identity: Option<PublicKey>,
|
||||
pub label: String,
|
||||
pub allowed_ips: Vec<String>,
|
||||
pub has_subnet_routes: bool,
|
||||
pub issues: Vec<crate::wireguard::PeerIssue>,
|
||||
pub mutable_identity: Option<PublicKey>,
|
||||
}
|
||||
|
||||
impl ClientDisplay {
|
||||
/// Whether a retained parser issue describes a valid address shape the
|
||||
/// client model cannot manage, rather than a malformed configuration.
|
||||
pub fn is_capability_limitation_issue(&self, issue: &crate::wireguard::PeerIssue) -> bool {
|
||||
matches!(
|
||||
issue,
|
||||
crate::wireguard::PeerIssue::UnsupportedAllowedIpShape { .. }
|
||||
| crate::wireguard::PeerIssue::MissingIpv4HostRoute
|
||||
)
|
||||
}
|
||||
|
||||
pub fn presented_issues(&self) -> impl Iterator<Item = &crate::wireguard::PeerIssue> {
|
||||
self.issues
|
||||
.iter()
|
||||
.filter(|issue| !self.is_capability_limitation_issue(issue))
|
||||
}
|
||||
}
|
||||
|
||||
/// Secret-free display projection of the current document and client state.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SessionDisplay {
|
||||
@@ -553,6 +572,7 @@ impl Application {
|
||||
identity,
|
||||
label,
|
||||
allowed_ips: peer.allowed_ips.iter().map(ToString::to_string).collect(),
|
||||
has_subnet_routes: peer.has_subnet_routes,
|
||||
issues: peer.issues.clone(),
|
||||
mutable_identity: projected
|
||||
.filter(|client| self.states.draft().get(&client.identity).is_some())
|
||||
|
||||
Reference in New Issue
Block a user