Skip to main content

rustfs_madmin/net/
mod.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use serde::{Deserialize, Serialize};
16
17use crate::health::NodeCommon;
18
19#[cfg(target_os = "linux")]
20pub fn get_net_info(addr: &str, iface: &str) -> NetInfo {
21    let mut ni = NetInfo::default();
22    ni.node_common.addr = addr.to_string();
23    ni.interface = iface.to_string();
24
25    ni
26}
27
28#[cfg(not(target_os = "linux"))]
29pub fn get_net_info(addr: &str, iface: &str) -> NetInfo {
30    NetInfo {
31        node_common: NodeCommon {
32            addr: addr.to_owned(),
33            error: Some("Not implemented for non-linux platforms".to_string()),
34        },
35        interface: iface.to_owned(),
36        ..Default::default()
37    }
38}
39
40#[derive(Debug, Default, Serialize, Deserialize)]
41pub struct NetInfo {
42    node_common: NodeCommon,
43    interface: String,
44    driver: String,
45    firmware_version: String,
46}