Skip to content

Commit

Permalink
add hostname to about
Browse files Browse the repository at this point in the history
  • Loading branch information
svenrademakers committed Mar 23, 2024
1 parent 8ec72c6 commit c12fbd5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use async_compression::Level;
use humansize::{format_size, DECIMAL};
use serde_json::json;
use std::collections::HashMap;
use std::io;
use std::ops::Deref;
use std::path::PathBuf;
use std::process::Command;
Expand Down Expand Up @@ -218,8 +219,11 @@ async fn get_about() -> impl Into<LegacyResponse> {
}
}

let hostname = read_hostname().await.unwrap_or_default();

json!(
{
"hostname": hostname,
"api": API_VERSION,
"version": version,
"buildtime": build_time,
Expand Down Expand Up @@ -314,6 +318,10 @@ async fn read_os_release() -> std::io::Result<HashMap<String, String>> {
Ok(results)
}

async fn read_hostname() -> io::Result<String> {
tokio::fs::read_to_string("/proc/sys/kernel/hostname").await
}

/// function is here for backwards compliance. Data is mostly a duplication of [`get_about`]
async fn get_system_information() -> impl Into<LegacyResponse> {
let version = env!("CARGO_PKG_VERSION");
Expand Down

0 comments on commit c12fbd5

Please sign in to comment.