mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: fixing windows compilation
This commit is contained in:
parent
c50ebf9991
commit
82389bb4b9
3 changed files with 54 additions and 1 deletions
15
network/ble_device_windows.go
Normal file
15
network/ble_device_windows.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type BLEDevice struct {
|
||||
LastSeen time.Time
|
||||
}
|
||||
|
||||
func NewBLEDevice() *BLEDevice {
|
||||
return &BLEDevice{
|
||||
LastSeen: time.Now(),
|
||||
}
|
||||
}
|
38
network/ble_windows.go
Normal file
38
network/ble_windows.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type BLEDevNewCallback func(dev *BLEDevice)
|
||||
type BLEDevLostCallback func(dev *BLEDevice)
|
||||
|
||||
type BLE struct {
|
||||
devices map[string]*BLEDevice
|
||||
newCb BLEDevNewCallback
|
||||
lostCb BLEDevLostCallback
|
||||
}
|
||||
|
||||
type bleJSON struct {
|
||||
Devices []*BLEDevice `json:"devices"`
|
||||
}
|
||||
|
||||
func NewBLE(newcb BLEDevNewCallback, lostcb BLEDevLostCallback) *BLE {
|
||||
return &BLE{
|
||||
devices: make(map[string]*BLEDevice),
|
||||
newCb: newcb,
|
||||
lostCb: lostcb,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BLE) MarshalJSON() ([]byte, error) {
|
||||
doc := bleJSON{
|
||||
Devices: make([]*BLEDevice, 0),
|
||||
}
|
||||
|
||||
for _, dev := range b.Devices() {
|
||||
doc.Devices = append(doc.Devices, dev)
|
||||
}
|
||||
|
||||
return json.Marshal(doc)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue