Skip to content

Commit a60a1e1

Browse files
committed
Use patched RustDDS
1 parent d637a52 commit a60a1e1

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ booster_sdk = { path = "booster_sdk" }
2626

2727
tokio = { version = "1.42", features = ["full"] }
2828
futures = "0.3"
29-
rustdds = "0.11.8"
29+
rustdds = { git = "https://github.com/oxkitsune/RustDDS.git", branch = "gijs/localhost-only"}
3030
serde = { version = "1.0", features = ["derive"] }
3131
serde_json = "1.0"
3232
thiserror = "1.0"

booster_sdk/src/dds/node.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use serde::{Serialize, de::DeserializeOwned};
44
use tokio::sync::mpsc;
55

6-
use rustdds::{DomainParticipant, Publisher, QosPolicyBuilder, Subscriber};
6+
use rustdds::{DomainParticipant, DomainParticipantBuilder, Publisher, QosPolicyBuilder, Subscriber};
77

88
use crate::types::{DdsError, Result};
99

@@ -12,6 +12,9 @@ use super::topics::TopicSpec;
1212
#[derive(Default, Debug, Clone)]
1313
pub struct DdsConfig {
1414
pub domain_id: u16,
15+
/// If set, restricts DDS discovery and traffic to the named network interfaces only
16+
/// (e.g. `vec!["eth0".into()]`). When `None`, all multicast-capable interfaces are used.
17+
pub only_networks: Option<Vec<String>>,
1518
}
1619

1720
#[derive(Clone)]
@@ -23,7 +26,18 @@ pub struct DdsNode {
2326

2427
impl DdsNode {
2528
pub fn new(config: DdsConfig) -> Result<Self> {
26-
let participant = DomainParticipant::new(config.domain_id)
29+
let loopback = if cfg!(target_os = "macos") {
30+
"lo0"
31+
} else {
32+
"lo"
33+
};
34+
let mut builder =
35+
DomainParticipantBuilder::new(config.domain_id).with_only_networks(vec![loopback.into()]);
36+
if let Some(networks) = config.only_networks {
37+
builder = builder.with_only_networks(networks);
38+
}
39+
let participant = builder
40+
.build()
2741
.map_err(|err| DdsError::InitializationFailed(err.to_string()))?;
2842
let qos = QosPolicyBuilder::new().build();
2943
let publisher = participant

booster_sdk/src/dds/rpc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct RpcClientOptions {
2121
pub default_timeout: Duration,
2222
pub startup_wait: Duration,
2323
pub service_topic: String,
24+
pub only_networks: Option<Vec<String>>,
2425
}
2526

2627
impl Default for RpcClientOptions {
@@ -33,6 +34,7 @@ impl Default for RpcClientOptions {
3334
// Wait once before the first RPC call so endpoint discovery can settle.
3435
startup_wait: Duration::from_millis(3000),
3536
service_topic: LOCO_API_TOPIC.to_owned(),
37+
only_networks: None,
3638
}
3739
}
3840
}
@@ -146,6 +148,7 @@ impl RpcClient {
146148
pub fn new(options: RpcClientOptions) -> Result<Self> {
147149
let node = DdsNode::new(super::DdsConfig {
148150
domain_id: options.domain_id,
151+
only_networks: options.only_networks.clone(),
149152
})?;
150153

151154
let service_topic = normalize_service_topic(&options.service_topic);

0 commit comments

Comments
 (0)