Skip to content

Commit

Permalink
Change overwrite behavior in transport logic instead of Endpoint
Browse files Browse the repository at this point in the history
This reverts commit 5157987.
  • Loading branch information
oteffahi committed Dec 9, 2024
1 parent f3f01de commit e215f61
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
3 changes: 1 addition & 2 deletions commons/zenoh-protocol/src/core/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,8 @@ impl ConfigMut<'_> {
self.0.address(),
self.0.metadata(),
parameters::from_iter(parameters::sort(parameters::join(
// Endpoint config overwrites incoming config
iter.map(|(k, v)| (k.borrow(), v.borrow())),
self.0.config().iter(),
iter.map(|(k, v)| (k.borrow(), v.borrow())),
))),
)?;

Expand Down
20 changes: 13 additions & 7 deletions io/zenoh-links/zenoh-link-tls/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use secrecy::ExposeSecret;
use webpki::anchor_from_trusted_cert;
use zenoh_config::Config as ZenohConfig;
use zenoh_link_commons::{
tcp::TcpSocketConfig, tls::WebPkiVerifierAnyServerName, ConfigurationInspector,
tcp::TcpSocketConfig, tls::WebPkiVerifierAnyServerName, ConfigurationInspector, BIND_INTERFACE,
TCP_RX_BUFFER_SIZE, TCP_TX_BUFFER_SIZE,
};
use zenoh_protocol::core::{
Expand Down Expand Up @@ -178,7 +178,7 @@ pub(crate) struct TlsServerConfig<'a> {
}

impl<'a> TlsServerConfig<'a> {
pub async fn new(config: &Config<'a>) -> ZResult<Self> {
pub async fn new(config: &'a Config<'_>) -> ZResult<Self> {
let tls_server_client_auth: bool = match config.get(TLS_ENABLE_MTLS) {
Some(s) => s
.parse()
Expand Down Expand Up @@ -277,8 +277,11 @@ impl<'a> TlsServerConfig<'a> {
server_config: sc,
tls_handshake_timeout,
tls_close_link_on_expiration,
// TODO: add interface binding
tcp_socket_config: TcpSocketConfig::new(tcp_tx_buffer_size, tcp_rx_buffer_size, None),
tcp_socket_config: TcpSocketConfig::new(
tcp_tx_buffer_size,
tcp_rx_buffer_size,
config.get(BIND_INTERFACE),
),
})
}

Expand Down Expand Up @@ -310,7 +313,7 @@ pub(crate) struct TlsClientConfig<'a> {
}

impl<'a> TlsClientConfig<'a> {
pub async fn new(config: &Config<'a>) -> ZResult<Self> {
pub async fn new(config: &'a Config<'_>) -> ZResult<Self> {
let tls_client_server_auth: bool = match config.get(TLS_ENABLE_MTLS) {
Some(s) => s
.parse()
Expand Down Expand Up @@ -440,8 +443,11 @@ impl<'a> TlsClientConfig<'a> {
Ok(TlsClientConfig {
client_config: cc,
tls_close_link_on_expiration,
// TODO: add interface binding
tcp_socket_config: TcpSocketConfig::new(tcp_tx_buffer_size, tcp_rx_buffer_size, None),
tcp_socket_config: TcpSocketConfig::new(
tcp_tx_buffer_size,
tcp_rx_buffer_size,
config.get(BIND_INTERFACE),
),
})
}

Expand Down
12 changes: 9 additions & 3 deletions io/zenoh-transport/src/multicast/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,15 @@ impl TransportManager {
.await?;
// Fill and merge the endpoint configuration
if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) {
endpoint
.config_mut()
.extend_from_iter(parameters::iter(config))?;
let mut config = parameters::Parameters::from(config.as_str());
// Overwrite config with current endpoint parameters
config.extend_from_iter(endpoint.config().iter());
endpoint = EndPoint::new(
endpoint.protocol(),
endpoint.address(),
endpoint.metadata(),
config.as_str(),
)?;
}

// Open the link
Expand Down
24 changes: 18 additions & 6 deletions io/zenoh-transport/src/unicast/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,15 @@ impl TransportManager {
.await?;
// Fill and merge the endpoint configuration
if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) {
endpoint
.config_mut()
.extend_from_iter(parameters::iter(config))?;
let mut config = parameters::Parameters::from(config.as_str());
// Overwrite config with current endpoint parameters
config.extend_from_iter(endpoint.config().iter());
endpoint = EndPoint::new(
endpoint.protocol(),
endpoint.address(),
endpoint.metadata(),
config.as_str(),
)?;
};
manager.new_listener(endpoint).await
}
Expand Down Expand Up @@ -705,9 +711,15 @@ impl TransportManager {
.await?;
// Fill and merge the endpoint configuration
if let Some(config) = self.config.endpoints.get(endpoint.protocol().as_str()) {
endpoint
.config_mut()
.extend_from_iter(parameters::iter(config))?;
let mut config = parameters::Parameters::from(config.as_str());
// Overwrite config with current endpoint parameters
config.extend_from_iter(endpoint.config().iter());
endpoint = EndPoint::new(
endpoint.protocol(),
endpoint.address(),
endpoint.metadata(),
config.as_str(),
)?;
};

// Create a new link associated by calling the Link Manager
Expand Down
Empty file.
Empty file.

0 comments on commit e215f61

Please sign in to comment.