Skip to content

Commit 9484f8e

Browse files
authored
Return whether core is connected (#163)
1 parent 78fe261 commit 9484f8e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/http.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use crate::{
4545

4646
pub(crate) static ENROLLMENT_COOKIE_NAME: &str = "defguard_proxy";
4747
pub(crate) static PASSWORD_RESET_COOKIE_NAME: &str = "defguard_proxy_password_reset";
48+
const DEFGUARD_CORE_CONNECTED_HEADER: &str = "defguard-core-connected";
4849
const DEFGUARD_CORE_VERSION_HEADER: &str = "defguard-core-version";
4950
const RATE_LIMITER_CLEANUP_PERIOD: Duration = Duration::from_secs(60);
5051
const X_FORWARDED_FOR: &str = "x-forwarded-for";
@@ -143,6 +144,17 @@ async fn core_version_middleware(
143144
}
144145
}
145146

147+
let core_connected = app_state.grpc_server.connected.load(Ordering::Relaxed);
148+
let core_connected_header = if core_connected {
149+
HeaderValue::from_static("true")
150+
} else {
151+
HeaderValue::from_static("false")
152+
};
153+
154+
response
155+
.headers_mut()
156+
.insert(DEFGUARD_CORE_CONNECTED_HEADER, core_connected_header);
157+
146158
response
147159
}
148160

0 commit comments

Comments
 (0)