#[derive(Debug)]
pub struct Global {
config: config::InstanceConfigGlobal,
+ local_rx: mpsc::Sender<RoutedPacket>,
all_clients: HashMap<ClientName, User>,
}
String,
)> = vec![];
- let (global, ipif) = config::startup(
+ let global = config::startup(
"hippotatd", LinkEnd::Server,
&opts.config, &opts.log, |ics|
{
})
}).collect();
+ let (local_rx_send, local_tx_recv) = mpsc::channel(
+ 50 // xxx configurable?
+ );
+
let global = Arc::new(Global {
config: global_config,
+ local_rx: local_rx_send,
all_clients,
});
});
tasks.push((task, format!("http server {}", addr)));
}
-
- Ok((global, ipif))
+
+ let global_ = global.clone();
+ let ipif = tokio::task::spawn(async move {
+ slocal::run(global_, local_tx_recv, ipif).await
+ .void_unwrap_err()
+ });
+ tasks.push((ipif, format!("ipif")));
+
+ Ok(global)
});
let died = future::select_all(
).await;
error!("xxx {:?}", &died);
- ipif.quitting(None).await;
-
dbg!(global);
}
use super::*;
#[allow(dead_code)] // xxx
-#[throws(PacketError)]
-pub async fn run(_global: &Global,
- _rx: mpsc::Receiver<RoutedPacket>) {
-
+#[allow(unused_variables)] // xxx
+pub async fn run(global: Arc<Global>,
+ rx: mpsc::Receiver<RoutedPacket>,
+ mut ipif: Ipif) -> Result<Void,AE> {
+ let r = async {
+ loop {
+ select!{
+ data = ipif.tx.next_segment() =>
+ {
+ let data = data.context("read from ipif")?;
+ }
+ }
+ }
+ }.await;
+
+ ipif.quitting(None).await;
+ r
}