From 062d95c1eb1c7818ad8e7c5195d1e4df20e30e92 Mon Sep 17 00:00:00 2001 From: link Date: Sat, 10 Dec 2022 17:42:05 +0800 Subject: [PATCH] done (#750) --- service/system.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/service/system.go b/service/system.go index cc83299..80a768c 100644 --- a/service/system.go +++ b/service/system.go @@ -1,6 +1,7 @@ package service import ( + "errors" "fmt" "io/ioutil" net2 "net" @@ -63,8 +64,15 @@ func (c *systemService) GetMacAddress() (string, error) { if err != nil { return "", err } - inter := interfaces[0] - return inter.HardwareAddr, nil + nets := MyService.System().GetNet(true) + for _, v := range interfaces { + for _, n := range nets { + if v.Name == n { + return v.HardwareAddr, nil + } + } + } + return "", errors.New("not found") } func (c *systemService) MkdirAll(path string) (int, error) {