Browse Source

fix hardward addr bug

tags/v1.3.0
liangzy 4 years ago
parent
commit
eebd6500f3
2 changed files with 8 additions and 1 deletions
  1. +1
    -1
      logs/es/es.go
  2. +7
    -0
      logs/es/sys.go

+ 1
- 1
logs/es/es.go View File

@@ -80,7 +80,7 @@ func (el *esLogger) WriteMsg(when time.Time, msg string, level int, lable string
vals["hostname"] = GetHostname()
vals["working_idr"] = Getwd()
vals["home_dir"] = GetUserHomename()
vals["hardware_addr"] = GetCurrentInterface().HardwareAddr
vals["hardware_addr"] = GetCurrentInterfaceHardwareAddr()
vals["client_addrs"] = GetCurrentInterfaceAddrs()

if el.IndexName == "" {


+ 7
- 0
logs/es/sys.go View File

@@ -15,6 +15,13 @@ func GetCurrentInterface() *net.Interface {
return nil
}

func GetCurrentInterfaceHardwareAddr() string {
if inter := GetCurrentInterface(); inter != nil {
return fmt.Sprintf("%s", inter.HardwareAddr)
}
return ""
}

func GetCurrentInterfaceAddrs() string {
if inter := GetCurrentInterface(); inter != nil {
if addrs, err := inter.Addrs(); err == nil {


Loading…
Cancel
Save