mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
8d2f0af82b
commit
d95373bfa8
6 changed files with 22 additions and 21 deletions
|
@ -118,7 +118,7 @@ func (w WiFiRecon) Author() string {
|
|||
return "Gianluca Braga <matrix86@protonmail.com>"
|
||||
}
|
||||
|
||||
func (w *WiFiRecon) getRow(station *network.WiFiStation) []string {
|
||||
func (w *WiFiRecon) getRow(station *network.Station) []string {
|
||||
sinceStarted := time.Since(w.Session.StartedAt)
|
||||
sinceFirstSeen := time.Since(station.FirstSeen)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/evilsocket/bettercap-ng/network"
|
||||
)
|
||||
|
||||
type ByRSSISorter []*network.WiFiStation
|
||||
type ByRSSISorter []*network.Station
|
||||
|
||||
func (a ByRSSISorter) Len() int { return len(a) }
|
||||
func (a ByRSSISorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
@ -15,7 +15,7 @@ func (a ByRSSISorter) Less(i, j int) bool {
|
|||
return a[i].RSSI > a[j].RSSI
|
||||
}
|
||||
|
||||
type ByChannelSorter []*network.WiFiStation
|
||||
type ByChannelSorter []*network.Station
|
||||
|
||||
func (a ByChannelSorter) Len() int { return len(a) }
|
||||
func (a ByChannelSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
@ -26,7 +26,7 @@ func (a ByChannelSorter) Less(i, j int) bool {
|
|||
return a[i].Channel < a[j].Channel
|
||||
}
|
||||
|
||||
type ByEssidSorter []*network.WiFiStation
|
||||
type ByEssidSorter []*network.Station
|
||||
|
||||
func (a ByEssidSorter) Len() int { return len(a) }
|
||||
func (a ByEssidSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
@ -37,7 +37,7 @@ func (a ByEssidSorter) Less(i, j int) bool {
|
|||
return a[i].ESSID() < a[j].ESSID()
|
||||
}
|
||||
|
||||
type ByWiFiSeenSorter []*network.WiFiStation
|
||||
type ByWiFiSeenSorter []*network.Station
|
||||
|
||||
func (a ByWiFiSeenSorter) Len() int { return len(a) }
|
||||
func (a ByWiFiSeenSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type OnHostResolvedCallback func(e *Endpoint)
|
||||
|
||||
type Endpoint struct {
|
||||
Index int `json:"-"`
|
||||
IP net.IP `json:"-"`
|
|
@ -5,13 +5,13 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type StationNewCallback func(s *WiFiStation)
|
||||
type StationLostCallback func(s *WiFiStation)
|
||||
type StationNewCallback func(s *Station)
|
||||
type StationLostCallback func(s *Station)
|
||||
|
||||
type WiFi struct {
|
||||
sync.Mutex
|
||||
Interface *Endpoint
|
||||
Stations map[string]*WiFiStation
|
||||
Stations map[string]*Station
|
||||
|
||||
newCb StationNewCallback
|
||||
lostCb StationLostCallback
|
||||
|
@ -20,17 +20,17 @@ type WiFi struct {
|
|||
func NewWiFi(iface *Endpoint, newcb StationNewCallback, lostcb StationLostCallback) *WiFi {
|
||||
return &WiFi{
|
||||
Interface: iface,
|
||||
Stations: make(map[string]*WiFiStation),
|
||||
Stations: make(map[string]*Station),
|
||||
newCb: newcb,
|
||||
lostCb: lostcb,
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WiFi) List() (list []*WiFiStation) {
|
||||
func (w *WiFi) List() (list []*Station) {
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
|
||||
list = make([]*WiFiStation, 0)
|
||||
list = make([]*Station, 0)
|
||||
for _, t := range w.Stations {
|
||||
list = append(list, t)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func (w *WiFi) Remove(mac string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (w *WiFi) AddIfNew(ssid, mac string, isAp bool, channel int, rssi int8) *WiFiStation {
|
||||
func (w *WiFi) AddIfNew(ssid, mac string, isAp bool, channel int, rssi int8) *Station {
|
||||
w.Lock()
|
||||
defer w.Unlock()
|
||||
|
||||
|
@ -60,7 +60,7 @@ func (w *WiFi) AddIfNew(ssid, mac string, isAp bool, channel int, rssi int8) *Wi
|
|||
return station
|
||||
}
|
||||
|
||||
newStation := NewWiFiStation(ssid, mac, isAp, channel, rssi)
|
||||
newStation := NewStation(ssid, mac, isAp, channel, rssi)
|
||||
w.Stations[mac] = newStation
|
||||
|
||||
if w.newCb != nil {
|
||||
|
@ -71,6 +71,6 @@ func (w *WiFi) AddIfNew(ssid, mac string, isAp bool, channel int, rssi int8) *Wi
|
|||
}
|
||||
|
||||
func (w *WiFi) Clear() error {
|
||||
w.Stations = make(map[string]*WiFiStation)
|
||||
w.Stations = make(map[string]*Station)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package network
|
||||
|
||||
type WiFiStation struct {
|
||||
type Station struct {
|
||||
*Endpoint
|
||||
IsAP bool
|
||||
Channel int
|
||||
|
@ -10,8 +10,8 @@ type WiFiStation struct {
|
|||
Encryption string
|
||||
}
|
||||
|
||||
func NewWiFiStation(essid, bssid string, isAp bool, channel int, rssi int8) *WiFiStation {
|
||||
return &WiFiStation{
|
||||
func NewStation(essid, bssid string, isAp bool, channel int, rssi int8) *Station {
|
||||
return &Station{
|
||||
Endpoint: NewEndpointNoResolve(MonitorModeAddress, bssid, essid, 0),
|
||||
IsAP: isAp,
|
||||
Channel: channel,
|
||||
|
@ -19,10 +19,10 @@ func NewWiFiStation(essid, bssid string, isAp bool, channel int, rssi int8) *WiF
|
|||
}
|
||||
}
|
||||
|
||||
func (s WiFiStation) BSSID() string {
|
||||
func (s Station) BSSID() string {
|
||||
return s.HwAddress
|
||||
}
|
||||
|
||||
func (s *WiFiStation) ESSID() string {
|
||||
func (s *Station) ESSID() string {
|
||||
return s.Hostname
|
||||
}
|
||||
|
|
|
@ -378,9 +378,9 @@ func (s *Session) Start() error {
|
|||
|
||||
s.Firewall = firewall.Make(s.Interface)
|
||||
|
||||
s.WiFi = network.NewWiFi(s.Interface, func(st *network.WiFiStation) {
|
||||
s.WiFi = network.NewWiFi(s.Interface, func(st *network.Station) {
|
||||
s.Events.Add("wifi.station.new", st)
|
||||
}, func(st *network.WiFiStation) {
|
||||
}, func(st *network.Station) {
|
||||
s.Events.Add("wifi.station.lost", st)
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue