1use std::env;
2
3use coreemu::Client;
4
5#[tokio::main]
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let remote = env::var("REMOTE_CORE").unwrap_or_else(|_| "http://127.0.0.1:50051".into());
8 let mut client = Client::connect(remote).await?;
9
10 let response = client.get_sessions().await?;
11
12 if response.is_empty() {
15 eprintln!("No sessions found");
16 return Ok(());
17 }
18 let session_id = response[0].id;
19
20 let response = client.get_session(session_id).await?.unwrap();
21
22 let mut links = Vec::new();
27 for l in response.links {
28 if l.r#type() == coreemu::core::link_type::Enum::Wireless {
30 let (n1, n2) = if l.node1_id < l.node2_id {
32 (l.node1_id, l.node2_id)
33 } else {
34 (l.node2_id, l.node1_id)
35 };
36 links.push(format!("{}-{}", n1, n2));
37 }
38 }
39 println!("{}", links.join(","));
40 Ok(())
41}