[control] UI socket: with [ui] socket control also serves the API on a 0660 Unix socket and trusts the proof only there; a socket upstream is refused unless it is the admin host on control's own socket; probes under Caddy reach it too
This commit is contained in:
@@ -315,6 +315,21 @@ pub async fn probe_upstream(
|
||||
"GET {path} HTTP/1.1\r\nHost: {host_header}\r\nUser-Agent: ianitor-health\r\nConnection: close\r\n\r\n"
|
||||
);
|
||||
let run = async {
|
||||
if let Some(path) = u.unix_path() {
|
||||
// A socket upstream (the admin host on control's own UI socket): plain HTTP.
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let s = tokio::net::UnixStream::connect(path)
|
||||
.await
|
||||
.map_err(|e| io_kind(&e))?;
|
||||
return ask(s, req.as_bytes()).await.map_err(|e| io_kind(&e));
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
let _ = path;
|
||||
return Err("refused");
|
||||
}
|
||||
}
|
||||
let tcp = match tokio::net::TcpStream::connect(u.authority()).await {
|
||||
Ok(t) => t,
|
||||
Err(e) => return Err(io_kind(&e)),
|
||||
|
||||
Reference in New Issue
Block a user