MCPcopy Create free account
hub / github.com/evilsocket/pwngrid / unitReport

Method unitReport

api/unit_report.go:18–44  ·  view source on GitHub ↗
(client string, unit *models.Unit, ap apReport)

Source from the content-addressed store, hash-verified

16}
17
18func (api *API) unitReport(client string, unit *models.Unit, ap apReport) error {
19 if parsed, err := net.ParseMAC(ap.BSSID); err != nil {
20 return fmt.Errorf("error while parsing wifi ap bssid %s from %s: %v", ap.BSSID, client, err)
21 } else {
22 // normalize
23 ap.BSSID = parsed.String()
24 }
25
26 if existing := unit.FindAccessPoint(ap.ESSID, ap.BSSID); existing == nil {
27 log.Debug("unit %s (%s %s) reporting new wifi access point %v", unit.Identity(), unit.Address,
28 unit.Country, ap)
29
30 newAP := models.AccessPoint{
31 Name: ap.ESSID,
32 Mac: ap.BSSID,
33 UnitID: unit.ID,
34 }
35
36 if err := models.Create(&newAP).Error; err != nil {
37 return fmt.Errorf("error creating ap %v: %v", newAP, err)
38 }
39 } else if err := models.Update(existing).Error; err != nil {
40 return fmt.Errorf("error updating ap %v: %v", existing, err)
41 }
42
43 return nil
44}
45
46func (api *API) UnitReportAP(w http.ResponseWriter, r *http.Request) {
47 unit := Authenticate(w, r)

Callers 2

UnitReportAPMethod · 0.95
UnitReportMultipleAPMethod · 0.95

Calls 4

CreateFunction · 0.92
UpdateFunction · 0.92
FindAccessPointMethod · 0.80
IdentityMethod · 0.80

Tested by

no test coverage detected