Skip to content

Commit f920426

Browse files
OmarTariq612eycorsican
authored andcommitted
propagate tun/cat listener errors to the user
1 parent 75502fc commit f920426

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

leaf/src/app/inbound/manager.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,13 @@ impl InboundManager {
345345
}
346346

347347
#[cfg(feature = "inbound-tun")]
348-
pub fn get_tun_runner(&self) -> Result<Runner> {
349-
if let Some(listener) = &self.tun_listener {
350-
return listener.listen();
351-
}
352-
Err(anyhow!("no tun inbound"))
348+
pub fn get_tun_runner(&self) -> Option<Result<Runner>> {
349+
self.tun_listener.as_ref().map(TunInboundListener::listen)
353350
}
354351

355352
#[cfg(feature = "inbound-cat")]
356-
pub fn get_cat_runner(&self) -> Result<Runner> {
357-
if let Some(listener) = &self.cat_listener {
358-
return listener.listen();
359-
}
360-
Err(anyhow!("no cat inbound"))
353+
pub fn get_cat_runner(&self) -> Option<Result<Runner>> {
354+
self.cat_listener.as_ref().map(CatInboundListener::listen)
361355
}
362356

363357
#[cfg(feature = "inbound-tun")]

leaf/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ pub fn start(rt_id: RuntimeId, opts: StartOptions) -> Result<(), Error> {
521521
}
522522

523523
#[cfg(feature = "inbound-tun")]
524-
if let Ok(r) = inbound_manager.get_tun_runner() {
525-
runners.push(r);
524+
if let Some(r) = inbound_manager.get_tun_runner() {
525+
runners.push(r.map_err(Error::Config)?);
526526
}
527527

528528
#[cfg(feature = "inbound-cat")]
529-
if let Ok(r) = inbound_manager.get_cat_runner() {
530-
runners.push(r);
529+
if let Some(r) = inbound_manager.get_cat_runner() {
530+
runners.push(r.map_err(Error::Config)?);
531531
}
532532

533533
#[cfg(all(feature = "inbound-tun", any(target_os = "macos", target_os = "linux")))]

0 commit comments

Comments
 (0)