8
0

fix hardward addr bug

Cette révision appartient à :
liangzy 2020-05-04 11:11:11 +08:00
Parent d6024cf64c
révision eebd6500f3
2 fichiers modifiés avec 8 ajouts et 1 suppressions

Voir le fichier

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

Voir le fichier

@ -15,6 +15,13 @@ func GetCurrentInterface() *net.Interface {
return nil return nil
} }
func GetCurrentInterfaceHardwareAddr() string {
if inter := GetCurrentInterface(); inter != nil {
return fmt.Sprintf("%s", inter.HardwareAddr)
}
return ""
}
func GetCurrentInterfaceAddrs() string { func GetCurrentInterfaceAddrs() string {
if inter := GetCurrentInterface(); inter != nil { if inter := GetCurrentInterface(); inter != nil {
if addrs, err := inter.Addrs(); err == nil { if addrs, err := inter.Addrs(); err == nil {