Skip to content

Commit

Permalink
fixup Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Oct 26, 2023
1 parent c758eba commit 11a6b5b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mullvad-daemon/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ pub(super) fn get_allowed_endpoint(endpoint: Endpoint) -> AllowedEndpoint {
];

AllowedEndpoint::new(
endpoint,
#[cfg(windows)]
clients,
endpoint,
)
}

Expand Down
29 changes: 27 additions & 2 deletions talpid-types/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl fmt::Display for AllowedEndpoint {
{
write!(f, "{} for", self.endpoint)?;
#[cfg(windows)]
for client in &self.clients {
for client in self.clients.iter() {
write!(
f,
" {}",
Expand All @@ -328,7 +328,24 @@ impl fmt::Display for AllowedEndpoint {

/// Clients which should be able to reach an allowed host in any tunnel state.
#[cfg(windows)]
pub struct AllowedClients(Vec<PathBuf>);
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct AllowedClients(std::sync::Arc<[PathBuf]>);

#[cfg(windows)]
impl std::ops::Deref for AllowedClients {
type Target = [PathBuf];

fn deref(&self) -> &Self::Target {
&self.0
}
}

#[cfg(windows)]
impl From<Vec<PathBuf>> for AllowedClients {
fn from(value: Vec<PathBuf>) -> Self {
Self(value.into())
}
}

/// Clients which should be able to reach an allowed host in any tunnel state.
#[cfg(unix)]
Expand All @@ -344,6 +361,14 @@ pub enum AllowedClients {
All,
}

#[cfg(windows)]
impl AllowedClients {
pub fn allow_all(&self) -> bool {
self.is_empty()
}
}

#[cfg(unix)]
impl AllowedClients {
pub fn allow_all(&self) -> bool {
matches!(self, AllowedClients::All)
Expand Down

0 comments on commit 11a6b5b

Please sign in to comment.