Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arqu committed Oct 2, 2024
1 parent 3e154ff commit 6a7cfcd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Builder {
discovery: self.discovery,
proxy_url: self.proxy_url,
dns_resolver,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: self.insecure_skip_relay_cert_verify,
};
Endpoint::bind(static_config, msock_opts, self.alpn_protocols).await
Expand Down
10 changes: 5 additions & 5 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub(crate) struct Options {
/// Skip verification of SSL certificates from relay servers
///
/// May only be used in tests.
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(iroh_docsrs, doc(cfg(any(test, feature = "test-utils"))))]
pub(crate) insecure_skip_relay_cert_verify: bool,
}
Expand All @@ -144,7 +144,7 @@ impl Default for Options {
discovery: None,
proxy_url: None,
dns_resolver: crate::dns::default_resolver().clone(),
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: false,
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ pub(crate) struct MagicSock {
/// Skip verification of SSL certificates from relay servers
///
/// May only be used in tests.
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(iroh_docsrs, doc(cfg(any(test, feature = "test-utils"))))]
insecure_skip_relay_cert_verify: bool,
}
Expand Down Expand Up @@ -1397,7 +1397,7 @@ impl Handle {
discovery,
dns_resolver,
proxy_url,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify,
} = opts;

Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl Handle {
pending_call_me_maybes: Default::default(),
direct_addr_update_state: DirectAddrUpdateState::new(),
dns_resolver,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify,
});

Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ impl RelayActor {
.can_ack_pings(true)
.is_preferred(my_relay.as_ref() == Some(&url1));

#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
let builder = builder.insecure_skip_cert_verify(self.msock.insecure_skip_relay_cert_verify);

let (dc, dc_receiver) = builder.build(
Expand Down
12 changes: 6 additions & 6 deletions iroh-net/src/relay/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ pub struct ClientBuilder {
/// Relay protocol
protocol: Protocol,
/// Allow self-signed certificates from relay servers
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(iroh_docsrs, doc(cfg(any(test, feature = "test-utils"))))]
insecure_skip_cert_verify: bool,
/// HTTP Proxy
Expand All @@ -236,7 +236,7 @@ impl ClientBuilder {
server_public_key: None,
url: url.into(),
protocol: Protocol::Relay,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_cert_verify: false,
proxy_url: None,
}
Expand Down Expand Up @@ -291,7 +291,7 @@ impl ClientBuilder {
/// Skip the verification of the relay server's SSL certificates.
///
/// May only be used in tests.
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(iroh_docsrs, doc(cfg(any(test, feature = "test-utils"))))]
pub fn insecure_skip_cert_verify(mut self, skip: bool) -> Self {
self.insecure_skip_cert_verify = skip;
Expand All @@ -317,7 +317,7 @@ impl ClientBuilder {
.expect("protocols supported by ring")
.with_root_certificates(roots)
.with_no_client_auth();
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
if self.insecure_skip_cert_verify {
warn!("Insecure config: SSL certificates from relay servers will be trusted without verification");
config
Expand Down Expand Up @@ -1050,12 +1050,12 @@ async fn resolve_host(
}

/// Used to allow self signed certificates in tests
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(iroh_docsrs, doc(cfg(any(test, feature = "test-utils"))))]
#[derive(Debug)]
struct NoCertVerifier;

#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
impl rustls::client::danger::ServerCertVerifier for NoCertVerifier {
fn verify_server_cert(
&self,
Expand Down
14 changes: 7 additions & 7 deletions iroh/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
dns_resolver: Option<DnsResolver>,
node_discovery: DiscoveryConfig,
docs_storage: DocsStorage,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: bool,
/// Callback to register when a gc loop is done
#[debug("callback")]
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Default for Builder<iroh_blobs::store::mem::Store> {
gc_policy: GcPolicy::Disabled,
docs_storage: DocsStorage::Disabled,
node_discovery: Default::default(),
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: false,
gc_done_callback: None,
blob_events: Default::default(),
Expand Down Expand Up @@ -286,7 +286,7 @@ impl<D: Map> Builder<D> {
gc_policy: GcPolicy::Disabled,
docs_storage,
node_discovery: Default::default(),
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: false,
gc_done_callback: None,
blob_events: Default::default(),
Expand Down Expand Up @@ -346,7 +346,7 @@ where
gc_policy: self.gc_policy,
docs_storage,
node_discovery: self.node_discovery,
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
insecure_skip_relay_cert_verify: false,
gc_done_callback: self.gc_done_callback,
blob_events: self.blob_events,
Expand Down Expand Up @@ -508,14 +508,14 @@ where
/// Skip verification of SSL certificates from relay servers
///
/// May only be used in tests.
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
pub fn insecure_skip_relay_cert_verify(mut self, skip_verify: bool) -> Self {
self.insecure_skip_relay_cert_verify = skip_verify;
self
}

/// Register a callback for when GC is done.
#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
pub fn register_gc_done_cb(mut self, cb: Box<dyn Fn() + Send>) -> Self {
self.gc_done_callback.replace(cb);
self
Expand Down Expand Up @@ -617,7 +617,7 @@ where
None => endpoint,
};

#[cfg(all(test, feature = "test-utils"))]
#[cfg(any(test, feature = "test-utils"))]
{
endpoint =
endpoint.insecure_skip_relay_cert_verify(self.insecure_skip_relay_cert_verify);
Expand Down

0 comments on commit 6a7cfcd

Please sign in to comment.