From f5df8329416796e1d687884b70be28518d825a30 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 2 Feb 2026 15:35:30 -0500 Subject: [PATCH] https://code.lotusguild.org/LotusGuild/proxDoc/issues/5 --- proxDoc.sh | 61 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/proxDoc.sh b/proxDoc.sh index 500ecfa..623c8d7 100755 --- a/proxDoc.sh +++ b/proxDoc.sh @@ -159,10 +159,13 @@ get_network_info() { get_detailed_network() { echo -e "\n${GREEN}=== Network Interface Statistics ===${NC}" - # Show only physical interfaces and bridges, skip virtual/firewall interfaces - for iface in $(ls /sys/class/net | grep -v lo | grep -v -E "^veth|^fwbr|^fwln|^fwpr|^tap"); do + + local iface + while IFS= read -r iface; do + [[ -z "$iface" ]] && continue ip -s link show "$iface" 2>/dev/null - done + done < <(get_physical_interfaces) + echo -e "\n${GREEN}=== Network Statistics ===${NC}" if command -v ss >/dev/null 2>&1; then ss -s @@ -232,42 +235,68 @@ get_memory_details() { get_nic_details() { echo -e "\n${GREEN}=== Network Interface Details ===${NC}" - # Show only physical interfaces and bridges, skip virtual/firewall interfaces - for iface in $(ls /sys/class/net | grep -v lo | grep -v -E "^veth|^fwbr|^fwln|^fwpr|^tap"); do + + local iface + while IFS= read -r iface; do + [[ -z "$iface" ]] && continue + echo -e "\n${GREEN}Interface: $iface${NC}" # Get driver info - if [ -L "/sys/class/net/$iface/device/driver" ]; then - driver=$(basename $(readlink /sys/class/net/$iface/device/driver)) + if [[ -L "/sys/class/net/$iface/device/driver" ]]; then + local driver + driver=$(basename "$(readlink "/sys/class/net/$iface/device/driver")") echo -e " Driver: $driver" fi # Get MAC address - if [ -f "/sys/class/net/$iface/address" ]; then - echo -e " MAC: $(cat /sys/class/net/$iface/address)" + if [[ -f "/sys/class/net/$iface/address" ]]; then + echo -e " MAC: $(cat "/sys/class/net/$iface/address")" fi # Get link state - if [ -f "/sys/class/net/$iface/operstate" ]; then - echo -e " State: $(cat /sys/class/net/$iface/operstate)" + if [[ -f "/sys/class/net/$iface/operstate" ]]; then + echo -e " State: $(cat "/sys/class/net/$iface/operstate")" fi # Use ethtool if available if command -v ethtool >/dev/null 2>&1; then # Get speed and duplex - link_info=$(ethtool $iface 2>/dev/null | grep -E "Speed:|Duplex:|Link detected:") - if [ -n "$link_info" ]; then - echo "$link_info" | while read line; do + local link_info + link_info=$(ethtool "$iface" 2>/dev/null | grep -E "Speed:|Duplex:|Link detected:") + if [[ -n "$link_info" ]]; then + echo "$link_info" | while IFS= read -r line; do echo -e " $line" done fi # Get firmware version - fw_ver=$(ethtool -i $iface 2>/dev/null | grep "firmware-version" | awk '{print $2}') - if [ -n "$fw_ver" ] && [ "$fw_ver" != "" ]; then + local fw_ver + fw_ver=$(ethtool -i "$iface" 2>/dev/null | grep "firmware-version" | awk '{print $2}') + if [[ -n "$fw_ver" ]]; then echo -e " Firmware: $fw_ver" fi fi + done < <(get_physical_interfaces) +} + +get_physical_interfaces() { + local iface + for iface in /sys/class/net/*; do + # Skip if glob didn't match anything + [[ -e "$iface" ]] || continue + + # Get just the interface name + iface=$(basename "$iface") + + # Skip loopback + [[ "$iface" == "lo" ]] && continue + + # Skip virtual/firewall interfaces + [[ "$iface" =~ ^(veth|fwbr|fwln|fwpr|tap) ]] && continue + + # This is a physical interface + echo "$iface" done }