Skip to content

Commit 49d300b

Browse files
Revert "Add Noise Direct connection shadowing via remote config"
1 parent 0ef36f8 commit 49d300b

File tree

11 files changed

+14
-188
lines changed

11 files changed

+14
-188
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
v0.81.1
22

33
- Enable negotiating permessage-deflate support for chat websocket connections, if configured.
4+
5+
- Net: remove Noise connection shadowing for staging Chat websocket connections.

rust/bridge/shared/testing/src/net_env.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub(crate) fn localhost_test_env_with_ports(
8181
ports.chat_port,
8282
root_certificate_der,
8383
),
84-
chat_noise_config: None,
8584
chat_ws_config: RECOMMENDED_CHAT_WS_CONFIG,
8685
cdsi: EnclaveEndpoint {
8786
domain_config: localhost_test_domain_config_with_port_and_cert(

rust/bridge/shared/types/src/net/chat.rs

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use http::uri::{InvalidUri, PathAndQuery};
1818
use http::{HeaderMap, HeaderName, HeaderValue};
1919
use libsignal_net::auth::Auth;
2020
use libsignal_net::chat::fake::FakeChatRemote;
21-
use libsignal_net::chat::noise::NoiseDirectConnectShadow;
2221
use libsignal_net::chat::server_requests::DisconnectCause;
2322
use libsignal_net::chat::ws::ListenerEvent;
2423
use libsignal_net::chat::{
@@ -32,7 +31,7 @@ use libsignal_net::infra::route::{
3231
UnresolvedHttpsServiceRoute,
3332
};
3433
use libsignal_net::infra::tcp_ssl::InvalidProxyConfig;
35-
use libsignal_net::infra::{Connection as _, EnableDomainFronting, EnforceMinimumTls};
34+
use libsignal_net::infra::{EnableDomainFronting, EnforceMinimumTls};
3635
use libsignal_net_chat::api::Unauth;
3736
use libsignal_protocol::Timestamp;
3837
use static_assertions::assert_impl_all;
@@ -144,7 +143,6 @@ impl AuthenticatedChatConnection {
144143
),
145144
)
146145
.await?;
147-
148146
Ok(Self {
149147
inner: MaybeChatConnection::WaitingForListener(
150148
tokio::runtime::Handle::current(),
@@ -183,39 +181,6 @@ impl AuthenticatedChatConnection {
183181
}
184182
}
185183

186-
fn maybe_shadow<'a>(
187-
connection_manager: &'a ConnectionManager,
188-
remote_config_key: RemoteConfigKey,
189-
languages: &LanguageList,
190-
) -> Option<NoiseDirectConnectShadow<'a>> {
191-
let ConnectionManager {
192-
user_agent,
193-
env,
194-
remote_config,
195-
connect,
196-
dns_resolver,
197-
..
198-
} = connection_manager;
199-
200-
let noise_config = env.chat_noise_config.as_ref()?.connect;
201-
202-
if !remote_config
203-
.lock()
204-
.expect("not poisoned")
205-
.is_enabled(remote_config_key)
206-
{
207-
return None;
208-
}
209-
210-
Some(NoiseDirectConnectShadow {
211-
route_resolver: connect.lock().expect("not poisoned").route_resolver.clone(),
212-
dns_resolver: dns_resolver.clone(),
213-
noise_config,
214-
language_list: languages.clone(),
215-
user_agent,
216-
})
217-
}
218-
219184
impl AsRef<tokio::sync::RwLock<MaybeChatConnection>> for AuthenticatedChatConnection {
220185
fn as_ref(&self) -> &tokio::sync::RwLock<MaybeChatConnection> {
221186
&self.inner
@@ -357,21 +322,6 @@ async fn establish_chat_connection(
357322
connection_manager: &ConnectionManager,
358323
headers: Option<chat::ChatHeaders>,
359324
) -> Result<chat::PendingChatConnection, ConnectError> {
360-
let noise_shadow = headers.as_ref().and_then(|headers| {
361-
let (languages, remote_config) = match headers {
362-
chat::ChatHeaders::Auth(auth) => (
363-
&auth.languages,
364-
RemoteConfigKey::ShadowAuthChatWithNoiseDirect,
365-
),
366-
chat::ChatHeaders::Unauth(unauth) => (
367-
&unauth.languages,
368-
RemoteConfigKey::ShadowUnauthChatWithNoiseDirect,
369-
),
370-
};
371-
372-
maybe_shadow(connection_manager, remote_config, languages)
373-
});
374-
375325
let ConnectionManager {
376326
env,
377327
dns_resolver,
@@ -436,7 +386,7 @@ async fn establish_chat_connection(
436386
true => EnablePermessageDeflate::Yes,
437387
false => EnablePermessageDeflate::No,
438388
};
439-
let connection = ChatConnection::start_connect_with(
389+
ChatConnection::start_connect_with(
440390
connection_resources,
441391
route_provider,
442392
user_agent,
@@ -449,30 +399,7 @@ async fn establish_chat_connection(
449399
Ok(_) => log::info!("successfully connected {auth_type} chat"),
450400
Err(e) => log::warn!("failed to connect {auth_type} chat: {e}"),
451401
})
452-
.await?;
453-
454-
let real_connection_info = connection.connection_info().route_info;
455-
let real_connection_was_direct =
456-
real_connection_info.proxy().is_none() && real_connection_info.domain_front().is_none();
457-
458-
if let Some(noise_shadow) = real_connection_was_direct.then_some(noise_shadow).flatten() {
459-
log::info!("shadowing {auth_type} chat with Noise Direct");
460-
let connect = noise_shadow.connect();
461-
tokio::spawn(async move {
462-
match connect.await {
463-
Ok(stream) => {
464-
let ip_type = stream.transport_info().ip_version();
465-
log::info!(
466-
"{auth_type} shadow: Noise Direct connection succeeded over IP{ip_type}"
467-
);
468-
drop(stream);
469-
}
470-
Err(e) => log::info!("{auth_type} shadow: Noise Direct connection failed: {e}"),
471-
}
472-
});
473-
}
474-
475-
Ok(connection)
402+
.await
476403
}
477404

478405
fn make_route_provider(

rust/bridge/shared/types/src/net/remote_config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ pub enum RemoteConfigKey {
4848
// TODO: Remove after enforcement has been enabled in production long enough without reported
4949
// issues.
5050
EnforceMinimumTls,
51-
/// If enabled, tries to connect via Noise Direct after establishing an authenticated chat connection.
52-
ShadowAuthChatWithNoiseDirect,
53-
/// If enabled, tries to connect via Noise Direct after establishing an unauthenticated chat connection.
54-
ShadowUnauthChatWithNoiseDirect,
5551
/// Determines whether a chat websocket connection attempts to negotiate permessage-deflate support.
5652
EnableChatPermessageDeflate,
5753
}
@@ -68,8 +64,6 @@ impl RemoteConfigKey {
6864
"chatRequestConnectionCheckTimeoutMillis"
6965
}
7066
Self::EnforceMinimumTls => "enforceMinimumTls",
71-
Self::ShadowAuthChatWithNoiseDirect => "shadowAuthChatWithNoise",
72-
Self::ShadowUnauthChatWithNoiseDirect => "shadowUnauthChatWithNoise",
7367
Self::EnableChatPermessageDeflate => "chatPermessageDeflate",
7468
}
7569
}

rust/net/infra/src/noise/direct.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use prost::Message as _;
1919
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
2020
use zerocopy::{FromBytes, IntoBytes};
2121

22-
use crate::Connection;
2322
use crate::noise::{FrameType, HandshakeAuthKind, Transport};
2423
use crate::proto::noise_direct::CloseReason;
2524
use crate::proto::noise_direct::close_reason::Code;
@@ -45,12 +44,6 @@ impl<S> DirectStream<S> {
4544

4645
static_assertions::assert_impl_all!(DirectStream<tokio::io::DuplexStream>: Transport);
4746

48-
impl<S: Connection> Connection for DirectStream<S> {
49-
fn transport_info(&self) -> crate::TransportInfo {
50-
self.inner.transport_info()
51-
}
52-
}
53-
5447
/// State for the [`AsyncRead`] side of a [`DirectStream`].
5548
#[derive(Debug, Default)]
5649
enum Read {

rust/net/infra/src/noise/stream.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use futures_util::{SinkExt as _, StreamExt as _};
1414
use snow::TransportState;
1515
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
1616

17-
use crate::Connection;
1817
use crate::noise::{FrameType, Transport};
1918

2019
/// Stream abstraction that encrypts/decrypts with [Noise].
@@ -66,12 +65,6 @@ impl<S> NoiseStream<S> {
6665
}
6766
}
6867

69-
impl<S: Connection> Connection for NoiseStream<S> {
70-
fn transport_info(&self) -> crate::TransportInfo {
71-
self.inner.transport_info()
72-
}
73-
}
74-
7568
impl<S: Transport + Unpin> AsyncRead for NoiseStream<S> {
7669
fn poll_read(
7770
self: Pin<&mut Self>,

rust/net/infra/src/route/describe.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ impl std::fmt::Display for UnresolvedRouteDescription {
134134
}
135135

136136
impl UnresolvedRouteDescription {
137-
pub fn proxy(&self) -> Option<ConnectionProxyKind> {
138-
self.proxy
139-
}
140-
141-
pub fn domain_front(&self) -> Option<&'static str> {
142-
self.front
143-
}
144-
145137
pub fn fake() -> Self {
146138
Self {
147139
front: None,

rust/net/src/chat/noise.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ pub use encrypted_stream::{
1919
Authorization, ChatNoiseConnector, ConnectError, ConnectMeta, ServerPublicKey,
2020
};
2121

22-
mod shadow;
23-
pub use shadow::NoiseDirectConnectShadow;
24-
2522
pub type ChatNoiseFragment = (Authorization, ConnectMeta);
2623

2724
#[derive(Clone, Debug, PartialEq)]

rust/net/src/chat/noise/encrypted_stream.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
1414
use uuid::Uuid;
1515

1616
use crate::chat::noise::{ChatNoiseFragment, HandshakeAuth};
17-
use crate::infra::Connection;
1817
use crate::infra::errors::{LogSafeDisplay, TransportConnectError};
1918
use crate::infra::noise::{
2019
EPHEMERAL_KEY_LEN, NoiseConnector, NoiseStream, STATIC_KEY_LEN, SendError, Transport,
@@ -138,12 +137,6 @@ where
138137
}
139138
}
140139

141-
impl<S: Connection> Connection for EncryptedStream<S> {
142-
fn transport_info(&self) -> libsignal_net_infra::TransportInfo {
143-
self.stream.transport_info()
144-
}
145-
}
146-
147140
impl<S: Transport + Unpin> AsyncRead for EncryptedStream<S> {
148141
fn poll_read(
149142
mut self: Pin<&mut Self>,

rust/net/src/connect_state.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ use itertools::Itertools as _;
1616
use libsignal_net_infra::dns::DnsResolver;
1717
use libsignal_net_infra::errors::{LogSafeDisplay, TransportConnectError};
1818
use libsignal_net_infra::route::{
19-
ComposedConnector, ConnectError, ConnectionOutcomeParams, ConnectionOutcomes,
20-
ConnectionProxyKind, Connector, ConnectorFactory, DelayBasedOnTransport, DescribeForLog,
21-
DescribedRouteConnector, DirectOrProxy, HttpRouteFragment, InterfaceChangedOr,
22-
InterfaceMonitor, LoggingConnector, ResettingConnectionOutcomes, ResolveHostnames,
23-
ResolveWithSavedDescription, ResolvedRoute, RouteProvider, RouteProviderContext,
24-
RouteProviderExt as _, RouteResolver, StaticTcpTimeoutConnector, ThrottlingConnector,
25-
TransportRoute, UnresolvedRouteDescription, UnresolvedTransportRoute,
26-
UnresolvedWebsocketServiceRoute, UsePreconnect, UsesTransport, VariableTlsTimeoutConnector,
27-
WebSocketRouteFragment, WebSocketServiceRoute,
19+
ComposedConnector, ConnectError, ConnectionOutcomeParams, ConnectionOutcomes, Connector,
20+
ConnectorFactory, DelayBasedOnTransport, DescribeForLog, DescribedRouteConnector,
21+
DirectOrProxy, HttpRouteFragment, InterfaceChangedOr, InterfaceMonitor, LoggingConnector,
22+
ResettingConnectionOutcomes, ResolveHostnames, ResolveWithSavedDescription, ResolvedRoute,
23+
RouteProvider, RouteProviderContext, RouteProviderExt as _, RouteResolver,
24+
StaticTcpTimeoutConnector, ThrottlingConnector, TransportRoute, UnresolvedRouteDescription,
25+
UnresolvedTransportRoute, UnresolvedWebsocketServiceRoute, UsePreconnect, UsesTransport,
26+
VariableTlsTimeoutConnector, WebSocketRouteFragment, WebSocketServiceRoute,
2827
};
2928
use libsignal_net_infra::tcp_ssl::{LONG_TCP_HANDSHAKE_THRESHOLD, LONG_TLS_HANDSHAKE_THRESHOLD};
3029
use libsignal_net_infra::timeouts::{
@@ -210,14 +209,6 @@ impl std::fmt::Display for RouteInfo {
210209
}
211210

212211
impl RouteInfo {
213-
pub fn proxy(&self) -> Option<ConnectionProxyKind> {
214-
self.unresolved.proxy()
215-
}
216-
217-
pub fn domain_front(&self) -> Option<&'static str> {
218-
self.unresolved.domain_front()
219-
}
220-
221212
pub fn fake() -> Self {
222213
Self {
223214
unresolved: UnresolvedRouteDescription::fake(),

0 commit comments

Comments
 (0)