56 lines
1.7 KiB
Rust
56 lines
1.7 KiB
Rust
impl Snapshot {
|
|
pub fn select_internal_on(
|
|
&self,
|
|
host: &str,
|
|
vhost_id: &str,
|
|
target: &str,
|
|
local: SocketAddr,
|
|
tls: bool,
|
|
) -> Option<&CompiledRoute> {
|
|
self.select_internal_on_arc(host, vhost_id, target, local, tls)
|
|
.map(Arc::as_ref)
|
|
}
|
|
|
|
pub fn select_internal_on_arc(
|
|
&self,
|
|
host: &str,
|
|
vhost_id: &str,
|
|
target: &str,
|
|
local: SocketAddr,
|
|
tls: bool,
|
|
) -> Option<&Arc<CompiledRoute>> {
|
|
Self::find_host_pattern(host, |pattern| {
|
|
let owns_host = self.fallbacks.get(pattern).is_some_and(|routes| {
|
|
routes.iter().any(|route| {
|
|
route
|
|
.frontend
|
|
.as_ref()
|
|
.is_some_and(|frontend| frontend.id == vhost_id)
|
|
&& route
|
|
.bindings
|
|
.iter()
|
|
.any(|binding| binding.matches(local, tls))
|
|
})
|
|
});
|
|
if !owns_host {
|
|
return None;
|
|
}
|
|
Some(self.routes.get(pattern).and_then(|routes| {
|
|
routes.iter().find(|route| {
|
|
route.internal
|
|
&& route.name == target
|
|
&& route
|
|
.frontend
|
|
.as_ref()
|
|
.is_some_and(|frontend| frontend.id == vhost_id)
|
|
&& route
|
|
.bindings
|
|
.iter()
|
|
.any(|binding| binding.matches(local, tls))
|
|
})
|
|
}))
|
|
})
|
|
.flatten()
|
|
}
|
|
}
|