github.com/zartbot/goflow@v0.0.0-20221001080520-456f7dfad288/service/identity/clientinfo.go (about) 1 package identity 2 3 import ( 4 "net" 5 ) 6 7 type WirelessClientInfo struct { 8 MAC string 9 UserName string 10 HostType string 11 Location string `json:"location"` 12 Speed int `json:"speed"` 13 Device struct { 14 HostName string 15 DeviceType string `json:"type"` 16 OS string 17 Version string 18 } `json:"deviceinfo"` 19 Network struct { 20 Ipv4 net.IP `json:"ipv4"` 21 Ipv6 net.IP `json:"ipv6"` 22 Gateway net.IP `json:"gateway"` 23 //DNS []net.IP `json:"dns-servers"` 24 } `json:"network"` 25 Wireless struct { 26 APMAC string `json:"ap-mac"` 27 RSSI int `json:"rssi"` 28 SNR int `json:"snr"` 29 SpatialStream int `json:"spatial-stream"` 30 PowerSaveMode int `json:"power-save"` 31 MaxSpeed float64 `json:"max-data-rate"` 32 RadioSlot int `json:"radio-slot"` 33 WlanID int `json:"wlan-id"` 34 SSID string `json:"ssid"` 35 State int `json:"state"` 36 AssocState int `json:"assoc-state"` 37 ConnectedTime uint32 `json:"connected-time"` 38 39 APNAME string `json:"ap-name"` 40 Channel int `json:"channel"` 41 Interference int `json:"interference"` 42 Utilization int `json:"utilization"` 43 APTxPower int `json:"ap-tx-power"` 44 PowerChangeReason int `json:"pwr-change-reason"` 45 APTrafficLoad int `json:"ap-traffic-load"` 46 APDataRate int `json:"ap-traffic-data-rate"` 47 MinAirQuality int `json:"min-air-quality` 48 AirQuality int `json:"air-quality` 49 Noise int `json:"noise"` 50 51 //AuthMode bool `json:"auth-mode"` 52 //AssociateAP APInfo `json:"ap"` 53 } `json:"wireless"` 54 } 55 56 func LookupUserAddr(ipaddr string) (map[string]interface{}, int) { 57 var result = make(map[string]interface{}) 58 var resulttype int = 0 59 //TODO: add static wired client info 60 if _mac, ok := Service["ARP"].Load(ipaddr); ok { 61 if mac, ok := _mac.(string); ok && len(mac) > 0 { 62 if clientinfo, valid := Service["WlanClient"].Load(mac); valid { 63 64 clientinfo, _ := clientinfo.(WirelessClientInfo) 65 result["HostInfo"] = clientinfo 66 //result = kjson.JsonFlatten(structs.Map(clientinfo.(WirelessClientInfo))) 67 result["hostType"] = "Client" 68 69 result["Location"] = clientinfo.Location 70 result["Owner"] = clientinfo.UserName 71 result["HostName"] = clientinfo.Device.HostName 72 result["OSInfo"] = clientinfo.Device.OS + ":" + clientinfo.Device.Version 73 resulttype = 64 74 return result, resulttype 75 } 76 } 77 } 78 return result, 0 79 }