mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-29 04:47:46 +02:00
wifi(linux): query associated station directly
mdlayher/wifi only dumps stations, which some full-MAC drivers (e.g. out-of-tree Realtek USB) answer with an empty list, leaving RSSI unavailable. Request the associated BSSID's station directly, as `iw link` does, and parse it with native.ParseStationInfo.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package wifi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
@@ -27,9 +28,17 @@ func (f *fakeLinuxClient) Interfaces() ([]*native.Interface, error) {
|
||||
func (f *fakeLinuxClient) BSS(i *native.Interface) (*native.BSS, error) {
|
||||
return f.bss[i.Name], f.bssErr
|
||||
}
|
||||
func (f *fakeLinuxClient) StationInfo(i *native.Interface) ([]*native.StationInfo, error) {
|
||||
func (f *fakeLinuxClient) Station(i *native.Interface, mac net.HardwareAddr) (*native.StationInfo, error) {
|
||||
f.stationCalls++
|
||||
return f.stations[i.Name], f.stationErr
|
||||
if f.stationErr != nil {
|
||||
return nil, f.stationErr
|
||||
}
|
||||
for _, station := range f.stations[i.Name] {
|
||||
if bytes.Equal(station.HardwareAddr, mac) {
|
||||
return station, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.New("no such station")
|
||||
}
|
||||
func (f *fakeLinuxClient) SetDeadline(d time.Time) error { f.deadline = d; return f.deadlineErr }
|
||||
func (f *fakeLinuxClient) Close() error { return nil }
|
||||
|
||||
Reference in New Issue
Block a user