Skip to content

Commit

Permalink
Chore: Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
oteffahi committed May 28, 2024
1 parent b4aaef9 commit 0a03e99
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 26 deletions.
3 changes: 2 additions & 1 deletion io/zenoh-link-commons/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ use core::{
hash::{Hash, Hasher},
ops::Deref,
};
use serde::Serialize;
use std::net::SocketAddr;

use async_trait::async_trait;
use serde::Serialize;
use zenoh_protocol::{
core::{EndPoint, Locator},
transport::BatchSize,
};
use zenoh_result::ZResult;

pub type LinkManagerUnicast = Arc<dyn LinkManagerUnicastTrait>;
#[async_trait]
pub trait LinkManagerUnicastTrait: Send + Sync {
Expand Down
2 changes: 0 additions & 2 deletions io/zenoh-links/zenoh-link-tls/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use tokio_util::sync::CancellationToken;
//use webpki::anchor_from_trusted_cert;
use x509_parser::prelude::*;
use zenoh_core::zasynclock;
//use zenoh_link_commons::tls::WebPkiVerifierAnyServerName;

use zenoh_link_commons::{
get_ip_interface_names, LinkAuthId, LinkAuthIdBuilder, LinkAuthType, LinkManagerUnicastTrait,
LinkUnicast, LinkUnicastTrait, ListenersUnicastIP, NewLinkChannelSender,
Expand Down
3 changes: 1 addition & 2 deletions io/zenoh-links/zenoh-link-vsock/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ use tokio_vsock::{
VMADDR_CID_LOCAL,
};
use zenoh_core::{zasyncread, zasyncwrite};
use zenoh_link_commons::LinkAuthId;
use zenoh_link_commons::{
LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender,
LinkAuthId, LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender,
};
use zenoh_protocol::{
core::{endpoint::Address, EndPoint, Locator},
Expand Down
3 changes: 1 addition & 2 deletions io/zenoh-links/zenoh-link-ws/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ use tokio::{
use tokio_tungstenite::{accept_async, tungstenite::Message, MaybeTlsStream, WebSocketStream};
use tokio_util::sync::CancellationToken;
use zenoh_core::{zasynclock, zasyncread, zasyncwrite};
use zenoh_link_commons::LinkAuthId;
use zenoh_link_commons::{
LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender,
LinkAuthId, LinkManagerUnicastTrait, LinkUnicast, LinkUnicastTrait, NewLinkChannelSender,
};
use zenoh_protocol::{
core::{EndPoint, Locator},
Expand Down
5 changes: 4 additions & 1 deletion io/zenoh-transport/src/unicast/authentication.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use zenoh_link::{LinkAuthId, LinkAuthType};

#[cfg(feature = "auth_usrpwd")]
use super::establishment::ext::auth::UsrPwdId;
use zenoh_link::{LinkAuthId, LinkAuthType};

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AuthId {
CertCommonName(String),
Username(String),
None,
}

impl From<LinkAuthId> for AuthId {
fn from(lid: LinkAuthId) -> Self {
match (lid.get_type(), lid.get_value()) {
Expand All @@ -18,6 +20,7 @@ impl From<LinkAuthId> for AuthId {
}
}
}

#[cfg(feature = "auth_usrpwd")]
impl From<UsrPwdId> for AuthId {
fn from(user_password_id: UsrPwdId) -> Self {
Expand Down
5 changes: 3 additions & 2 deletions io/zenoh-transport/src/unicast/establishment/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
#[cfg(feature = "auth_usrpwd")]
use super::ext::auth::UsrPwdId;
use std::time::Duration;

use async_trait::async_trait;
use rand::Rng;
use tokio::sync::Mutex;
Expand All @@ -32,6 +31,8 @@ use zenoh_protocol::{
};
use zenoh_result::ZResult;

#[cfg(feature = "auth_usrpwd")]
use super::ext::auth::UsrPwdId;
#[cfg(feature = "shared-memory")]
use super::ext::shm::AuthSegment;
#[cfg(feature = "shared-memory")]
Expand Down
4 changes: 2 additions & 2 deletions io/zenoh-transport/src/unicast/establishment/open.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(feature = "auth_usrpwd")]
use crate::unicast::establishment::ext::auth::UsrPwdId;
//
// Copyright (c) 2022 ZettaScale Technology
//
Expand Down Expand Up @@ -34,6 +32,8 @@ use zenoh_result::ZResult;
use super::ext::shm::AuthSegment;
#[cfg(feature = "shared-memory")]
use crate::shm::TransportShmConfig;
#[cfg(feature = "auth_usrpwd")]
use crate::unicast::establishment::ext::auth::UsrPwdId;
use crate::{
common::batch::BatchConfig,
unicast::{
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-transport/src/unicast/lowlatency/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use super::super::authentication::AuthId;
use std::{
sync::{Arc, RwLock as SyncRwLock},
time::Duration,
Expand All @@ -33,6 +32,7 @@ use zenoh_result::{zerror, ZResult};
use crate::stats::TransportStats;
use crate::{
unicast::{
authentication::AuthId,
link::{LinkUnicastWithOpenAck, TransportLinkUnicast},
transport_unicast_inner::{AddLinkResult, TransportUnicastTrait},
TransportConfigUnicast,
Expand Down
7 changes: 3 additions & 4 deletions io/zenoh-transport/src/unicast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ use std::{
sync::{Arc, Weak},
};

use self::authentication::AuthId;
#[cfg(feature = "auth_usrpwd")]
use self::establishment::ext::auth::UsrPwdId;

#[cfg(feature = "transport_multilink")]
use establishment::ext::auth::ZPublicKey;
pub use manager::*;
Expand All @@ -46,6 +42,9 @@ use self::transport_unicast_inner::TransportUnicastTrait;
use super::{TransportPeer, TransportPeerEventHandler};
#[cfg(feature = "shared-memory")]
use crate::shm::TransportShmConfig;
use crate::unicast::authentication::AuthId;
#[cfg(feature = "auth_usrpwd")]
use crate::unicast::establishment::ext::auth::UsrPwdId;

/*************************************/
/* TRANSPORT UNICAST */
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-transport/src/unicast/universal/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// Contributors:
// ZettaScale Zenoh Team, <[email protected]>
//
use super::super::authentication::AuthId;
use std::{
fmt::DebugStruct,
sync::{Arc, RwLock},
Expand All @@ -29,6 +28,7 @@ use zenoh_protocol::{
};
use zenoh_result::{bail, zerror, ZResult};

use super::super::authentication::AuthId;
#[cfg(feature = "stats")]
use crate::stats::TransportStats;
use crate::{
Expand Down
7 changes: 4 additions & 3 deletions zenoh/src/net/routing/interceptor/access_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ use zenoh_protocol::{
network::{Declare, DeclareBody, NetworkBody, NetworkMessage, Push, Request},
zenoh::{PushBody, RequestBody},
};
use zenoh_transport::unicast::authentication::AuthId;

use zenoh_result::ZResult;
use zenoh_transport::{multicast::TransportMulticast, unicast::TransportUnicast};
use zenoh_transport::{
multicast::TransportMulticast,
unicast::{authentication::AuthId, TransportUnicast},
};

use super::{
authorization::PolicyEnforcer, EgressInterceptor, IngressInterceptor, InterceptorFactory,
Expand Down
12 changes: 7 additions & 5 deletions zenoh/tests/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
// ZettaScale Zenoh Team, <[email protected]>
//
mod test {
use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::{
fs,
path::Path,
sync::{Arc, Mutex},
time::Duration,
};

use tokio::runtime::Handle;
use zenoh::prelude::*;
use zenoh_core::{zlock, ztimeout};

use std::fs;
use std::path::Path;

const TIMEOUT: Duration = Duration::from_secs(60);
const SLEEP: Duration = Duration::from_secs(1);
const KEY_EXPR: &str = "test/demo";
Expand Down

0 comments on commit 0a03e99

Please sign in to comment.