|
|
|
@@ -1,6 +1,8 @@ |
|
|
|
package utils |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"github.com/AFASystems/presence/internal/pkg/common/appcontext" |
|
|
|
"github.com/AFASystems/presence/internal/pkg/model" |
|
|
|
) |
|
|
|
@@ -38,16 +40,18 @@ func RemoveFlagBytes(b []byte) []byte { |
|
|
|
} |
|
|
|
|
|
|
|
// Generate event based on the Beacon type |
|
|
|
func LoopADStructures(b []byte, i [][2]int, id string, parserRegistry *model.ParserRegistry) appcontext.BeaconEvent { |
|
|
|
func LoopADStructures(b []byte, i [][2]int, id string, parserRegistry *model.ParserRegistry, beacon string) appcontext.BeaconEvent { |
|
|
|
be := appcontext.BeaconEvent{} |
|
|
|
for _, r := range i { |
|
|
|
ad := b[r[0]:r[1]] |
|
|
|
if !isValidADStructure(ad) { |
|
|
|
fmt.Println("invalid ad structure: ", beacon) |
|
|
|
break |
|
|
|
} |
|
|
|
for name, parser := range parserRegistry.ParserList { |
|
|
|
if parser.CanParse(ad) { |
|
|
|
event, ok := parser.Parse(name, ad) |
|
|
|
fmt.Println("parser can parse: ", name) |
|
|
|
if ok { |
|
|
|
event.ID = id |
|
|
|
event.Name = id |
|
|
|
@@ -55,6 +59,7 @@ func LoopADStructures(b []byte, i [][2]int, id string, parserRegistry *model.Par |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// fmt.Println("no parser can parse: ", beacon) |
|
|
|
} |
|
|
|
|
|
|
|
return be |
|
|
|
|