issue banner: avoid depending on proxmox crate for hostname

While this slightly duplicates code we just do not profit from the
central, lazy static variant here, as that is only really useful in
daemons to avoid doing frequent syscalls there.

proxmox just pull in far to much (e.g., tokio) and duplicating that
one line of simple code has no real maintenance cost, so just go for
that and use the nix crate directly.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-07-19 16:32:48 +02:00
parent 3fa1b4b48c
commit 513d019ac3
2 changed files with 5 additions and 3 deletions

View File

@ -5,4 +5,4 @@ authors = ["Proxmox Support Team <support@proxmox.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
proxmox = { version = "0.11.5", default-features = false, features = [] } nix = "0.19.1"

View File

@ -2,10 +2,12 @@ use std::fmt::Write;
use std::fs; use std::fs;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use proxmox::tools; use nix::sys::utsname::uname;
fn main() { fn main() {
let nodename = tools::nodename(); let uname = uname(); // save on stack to avoid to_owned() allocation below
let nodename = uname.nodename().split('.').next().unwrap();
let addr = format!("{}:8007", nodename); let addr = format!("{}:8007", nodename);
let mut banner = format!( let mut banner = format!(