mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 14:03:17 -07:00
more lint driven refactoring
This commit is contained in:
parent
7919cda5ec
commit
0de6f3a76e
57 changed files with 168 additions and 241 deletions
|
@ -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 ""
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue