more lint driven refactoring

This commit is contained in:
evilsocket 2018-04-24 18:26:16 +02:00
commit 0de6f3a76e
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
57 changed files with 168 additions and 241 deletions

View file

@ -65,7 +65,7 @@ func (a *Aliases) Get(mac string) string {
a.Lock()
defer a.Unlock()
if alias, found := a.data[mac]; found == true {
if alias, found := a.data[mac]; found {
return alias
}
return ""

View file

@ -58,7 +58,7 @@ func ArpUpdate(iface string) (ArpTable, error) {
func ArpLookup(iface string, address string, refresh bool) (string, error) {
// Refresh ARP table if first run or if a force refresh has been instructed.
if ArpParsed() == false || refresh == true {
if ArpParsed() == false || refresh {
if _, err := ArpUpdate(iface); err != nil {
return "", err
}
@ -68,7 +68,7 @@ func ArpLookup(iface string, address string, refresh bool) (string, error) {
defer arpLock.RUnlock()
// Lookup the hardware address of this ip.
if mac, found := arpTable[address]; found == true {
if mac, found := arpTable[address]; found {
return mac, nil
}
@ -76,7 +76,7 @@ func ArpLookup(iface string, address string, refresh bool) (string, error) {
}
func ArpInverseLookup(iface string, mac string, refresh bool) (string, error) {
if ArpParsed() == false || refresh == true {
if ArpParsed() == false || refresh {
if _, err := ArpUpdate(iface); err != nil {
return "", err
}

View file

@ -58,7 +58,7 @@ func (b *BLE) AddIfNew(id string, p gatt.Peripheral, a *gatt.Advertisement, rssi
defer b.Unlock()
id = NormalizeMac(id)
if dev, found := b.devices[id]; found == true {
if dev, found := b.devices[id]; found {
dev.LastSeen = time.Now()
dev.RSSI = rssi
dev.Advertisement = a
@ -80,7 +80,7 @@ func (b *BLE) Remove(id string) {
defer b.Unlock()
id = NormalizeMac(id)
if dev, found := b.devices[id]; found == true {
if dev, found := b.devices[id]; found {
delete(b.devices, id)
if b.lostCb != nil {
b.lostCb(dev)

View file

@ -77,7 +77,7 @@ func (lan *LAN) Get(mac string) (*Endpoint, bool) {
lan.Lock()
defer lan.Unlock()
if e, found := lan.hosts[mac]; found == true {
if e, found := lan.hosts[mac]; found {
return e, true
}
return nil, false
@ -106,7 +106,7 @@ func (lan *LAN) WasMissed(mac string) bool {
lan.Lock()
defer lan.Unlock()
if ttl, found := lan.ttl[mac]; found == true {
if ttl, found := lan.ttl[mac]; found {
return ttl < LANDefaultttl
}
return true

View file

@ -42,7 +42,7 @@ func (m *Meta) Get(name string) interface{} {
m.Lock()
defer m.Unlock()
if v, found := m.m[name]; found == true {
if v, found := m.m[name]; found {
return v
}
return ""
@ -75,7 +75,7 @@ func (m *Meta) GetOr(name string, dflt interface{}) interface{} {
m.Lock()
defer m.Unlock()
if v, found := m.m[name]; found == true {
if v, found := m.m[name]; found {
return v
}
return dflt

View file

@ -90,7 +90,7 @@ func ParseTargets(targets string, aliasMap *Aliases) (ips []net.IP, macs []net.H
// check and resolve aliases
for _, alias := range aliasParser.FindAllString(targets, -1) {
if mac, found := aliasMap.Find(alias); found == true {
if mac, found := aliasMap.Find(alias); found {
mac = NormalizeMac(mac)
hw, err := net.ParseMAC(mac)
if err != nil {

View file

@ -22936,7 +22936,7 @@ func OuiLookup(mac string) string {
octects := strings.Split(mac, ":")
if len(octects) > 3 {
prefix := octects[0] + octects[1] + octects[2]
if vendor, found := oui[prefix]; found == true {
if vendor, found := oui[prefix]; found {
return vendor
}
}

View file

@ -162,7 +162,7 @@ func (w *WiFi) GetClient(mac string) (*Station, bool) {
mac = NormalizeMac(mac)
for _, ap := range w.aps {
if client, found := ap.Get(mac); found == true {
if client, found := ap.Get(mac); found {
return client, true
}
}

View file

@ -43,7 +43,7 @@ func (ap *AccessPoint) Get(bssid string) (*Station, bool) {
defer ap.Unlock()
bssid = NormalizeMac(bssid)
if s, found := ap.clients[bssid]; found == true {
if s, found := ap.clients[bssid]; found {
return s, true
}
return nil, false
@ -55,7 +55,7 @@ func (ap *AccessPoint) AddClient(bssid string, frequency int, rssi int8) *Statio
bssid = NormalizeMac(bssid)
if s, found := ap.clients[bssid]; found == true {
if s, found := ap.clients[bssid]; found {
// update
s.Frequency = frequency
s.RSSI = rssi