omyacid: properly detect unregistered IPs

This commit is contained in:
snow flurry 2024-08-18 19:41:51 -07:00
parent 0cb3aea62e
commit 19a08abb52

View file

@ -99,7 +99,7 @@ async fn get_vendor_data(
// admin username from an unknown instance.
if let IpAddr::V4(ip) = addr.ip() {
match ctx.get_instance(ip).await {
Ok(_) => {
Ok(Some(_)) => {
let data = model::VendorData {
username: Some(&ctx.cfg().cloud.admin_user),
};
@ -108,14 +108,14 @@ async fn get_vendor_data(
StatusCode::INTERNAL_SERVER_ERROR
})
}
Ok(None) => {
tracing::warn!("Request from unregistered server {ip}");
Err(StatusCode::FORBIDDEN)
}
Err(err) => {
tracing::error!("{err}");
Err(StatusCode::INTERNAL_SERVER_ERROR)
}
_ => {
tracing::warn!("Request from unregistered server {ip}");
Err(StatusCode::FORBIDDEN)
}
}
} else {
Err(StatusCode::BAD_REQUEST)