mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Reuse host hook keys during inbound hook resolution
This commit is contained in:
@@ -183,17 +183,26 @@ impl HookTable {
|
||||
return_path: &[String],
|
||||
hook_id: u64,
|
||||
peer_path: &[String],
|
||||
) -> Option<HookKey> {
|
||||
let host_key = HookKey::new(return_path.to_vec(), hook_id);
|
||||
self.resolve_active_key_for_host(&host_key, peer_path)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn resolve_active_key_for_host(
|
||||
&self,
|
||||
host_key: &HookKey,
|
||||
peer_path: &[String],
|
||||
) -> Option<HookKey> {
|
||||
if let Some(key) = self
|
||||
.active_by_peer
|
||||
.get(&hook_id)
|
||||
.get(&host_key.hook_id)
|
||||
.and_then(|peer_paths| peer_paths.get(peer_path))
|
||||
{
|
||||
return Some(key.clone());
|
||||
}
|
||||
|
||||
let host_key = HookKey::new(return_path.to_vec(), hook_id);
|
||||
self.active.contains_key(&host_key).then_some(host_key)
|
||||
self.active.contains_key(host_key).then(|| host_key.clone())
|
||||
}
|
||||
|
||||
/// Marks the local side finished and returns `true` once both sides are finished.
|
||||
|
||||
Reference in New Issue
Block a user