scanning and attack modes wokring without serious hangs

This commit is contained in:
freqyXin 2021-05-13 22:54:10 -07:00
parent 77329e319b
commit 45358c285d
3 changed files with 33 additions and 12 deletions

10
main.go

@ -24,6 +24,16 @@ func init() {
// print banner for style points
// dust.Splash()
flag.Parse()
if *projVars.AFlag {
projVars.AttackMode = true
}
if *projVars.DFlag {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
ScanMgr = &scanStuff.Meta{
Count: 0,
Scans: make(map[int]*scanStuff.Scan),

@ -1,6 +1,7 @@
package scanStuff
import (
"fmt"
"protomolecule/src/dust"
"protomolecule/src/eros"
projVars "protomolecule/src/vars"
@ -133,7 +134,25 @@ func (s *Scan) Start() error {
TargetDevice, err := projVars.ScanAdapter.Connect(result.Address, bluetooth.ConnectionParams{})
//start := time.Now()
//var t int
var timeDealy = 150 * time.Millisecond
var tick <-chan time.Time
if tick == nil {
endTime := time.After(timeDealy)
select {
case <-endTime:
fmt.Println("Yes Finally!")
TargetDevice.Disconnect()
endTime = nil
default:
fmt.Println("not yet")
time.Sleep(50 * time.Millisecond) // simulate work
}
}
if err != nil {
log.Err(err).Msg("CONNECTION_ERROR")

@ -35,18 +35,10 @@ var AttackAdapter = bluetooth.DefaultAdapter
//Device to be targeted --not fully implemented
//var Target = flag.String("t", "00:00:00:00:00:00", "Target device to attack")
var dFlag = flag.Bool("d", false, "global debug logging and pretty printing")
var aFlag = flag.Bool("a", false, "attack mode")
var DFlag = flag.Bool("d", false, "global debug logging and pretty printing")
var AFlag = flag.Bool("a", false, "attack mode")
flag.Parse()
if *aFlag {
projVars.AttackMode = true
}
if *dFlag {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
//flag.Parse()
//var attacker bluetooth.Addresser
//var connected bool