98 lines
2.2 KiB
Go
98 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"protomolecule/src/dust"
|
|
"protomolecule/src/eros"
|
|
"protomolecule/src/scanStuff"
|
|
projVars "protomolecule/src/vars"
|
|
"time"
|
|
|
|
//projVars "protomolecule/src/vars"
|
|
|
|
"github.com/rs/zerolog"
|
|
"github.com/rs/zerolog/log"
|
|
//"git.tcp.direct/kayos/prototooth"
|
|
)
|
|
|
|
var ScanMgr *scanStuff.Meta
|
|
|
|
func init() {
|
|
flag.Parse()
|
|
|
|
if *projVars.AFlag {
|
|
projVars.AttackMode = true
|
|
}
|
|
|
|
if *projVars.DFlag {
|
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
|
}
|
|
|
|
if *projVars.TFlag {
|
|
projVars.TrackingMode = true
|
|
}
|
|
|
|
// Initializing an instance of our scan manager to keep track of concurrent scans
|
|
// NOTE: Devices are kept track of per Scan via a nested map of eros.Device instances
|
|
//
|
|
// TODO: Get all of this management stuff into its own package (structs and maps and initialization of the former)
|
|
// TODO: Name these structs and maps and instances more uniformly and idiomatically
|
|
ScanMgr = &scanStuff.Meta{
|
|
Count: 0,
|
|
Scans: make(map[int]*scanStuff.Scan),
|
|
}
|
|
|
|
// TODO: make this a command line argument
|
|
var logDir string = "./.logs/"
|
|
|
|
// assure the log directory exists
|
|
err := os.MkdirAll(logDir, 0755)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
|
|
// define log file itself using the current date and time
|
|
Now := time.Now()
|
|
date := Now.Format(time.RFC3339)
|
|
logFileName := date + ".log"
|
|
lf, err := os.OpenFile(logDir+logFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
|
|
// define pretty printer
|
|
consoleWriter := zerolog.ConsoleWriter{Out: os.Stderr}
|
|
|
|
// initialize simultaneous pretty printing and json logging
|
|
multi := zerolog.MultiLevelWriter(consoleWriter, lf)
|
|
log.Logger = zerolog.New(multi).With().Timestamp().Logger()
|
|
|
|
// suppress debug messages unless -d is called
|
|
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
|
|
|
log.Debug().Msg("Logging initialized")
|
|
|
|
// see ./src/eros
|
|
log.Debug().Msg("Initializing database engine")
|
|
eros.Awaken()
|
|
}
|
|
|
|
func main() {
|
|
var scan *scanStuff.Scan
|
|
|
|
scan = ScanMgr.NewScan()
|
|
|
|
//time.Sleep(30 * time.Millisecond)
|
|
dust.Must("Scan", scan.Start())
|
|
|
|
/*
|
|
connectToStuff := func(addr bluetooth.Addresser, device *bluetooth.Device) {
|
|
d, _ := adapter.Connect(addr, bluetooth.ConnectionParams{}, err ==
|
|
*device == d)
|
|
color.Red("Trying a connection", addr)
|
|
}
|
|
*/
|
|
|
|
}
|