14.04.2026 Update
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
type InterfaceStats struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"` // up, down, unknown
|
||||
State string `json:"state"`
|
||||
IPv4 string `json:"ipv4"`
|
||||
IPv4Mask string `json:"ipv4_mask"`
|
||||
IPv6 []string `json:"ipv6"`
|
||||
@@ -20,7 +20,8 @@ type InterfaceStats struct {
|
||||
TxBytes uint64 `json:"tx_bytes"`
|
||||
RxPackets uint64 `json:"rx_packets"`
|
||||
TxPackets uint64 `json:"tx_packets"`
|
||||
Mode string `json:"mode"` // dhcp, static, loopback, manual, unknown
|
||||
Mode string `json:"mode"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// GetInterfaces returns all network interface names from /sys/class/net.
|
||||
@@ -40,7 +41,6 @@ func GetInterfaces() ([]string, error) {
|
||||
func GetInterfaceStats(name string) (*InterfaceStats, error) {
|
||||
s := &InterfaceStats{Name: name, IPv6: []string{}}
|
||||
|
||||
// Operational state
|
||||
if raw, err := os.ReadFile("/sys/class/net/" + name + "/operstate"); err == nil {
|
||||
s.State = strings.TrimSpace(string(raw))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user