fix: fixing windows compilation

This commit is contained in:
evilsocket 2018-02-26 19:13:43 +01:00
commit 82389bb4b9
3 changed files with 54 additions and 1 deletions

View file

@ -165,7 +165,7 @@ rm -rf $BUILD_FOLDER
mkdir $BUILD_FOLDER
cd $BUILD_FOLDER
build_android_arm bettercap_android_arm_$VERSION
# build_android_arm bettercap_android_arm_$VERSION
build_linux_amd64 bettercap_linux_amd64_$VERSION
build_linux_arm7 bettercap_linux_arm7_$VERSION
build_linux_mips bettercap_linux_mips_$VERSION

View 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
View 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)
}