MCPcopy
hub / github.com/bettercap/bettercap / sessionRoute

Method sessionRoute

modules/api_rest/api_rest_controller.go:320–378  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

318}
319
320func (mod *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) {
321 mod.setSecurityHeaders(w)
322
323 if !mod.checkAuth(r) {
324 mod.setAuthFailed(w, r)
325 return
326 } else if r.Method == "POST" {
327 mod.runSessionCommand(w, r)
328 return
329 } else if r.Method != "GET" {
330 http.Error(w, "Bad Request", 400)
331 return
332 }
333
334 mod.Session.Lock()
335 defer mod.Session.Unlock()
336
337 path := r.URL.Path
338 switch {
339 case path == "/api/session":
340 mod.showSession(w, r)
341
342 case path == "/api/session/env":
343 mod.showEnv(w, r)
344
345 case path == "/api/session/gateway":
346 mod.showGateway(w, r)
347
348 case path == "/api/session/interface":
349 mod.showInterface(w, r)
350
351 case strings.HasPrefix(path, "/api/session/modules"):
352 mod.showModules(w, r)
353
354 case strings.HasPrefix(path, "/api/session/lan"):
355 mod.showLAN(w, r)
356
357 case path == "/api/session/options":
358 mod.showOptions(w, r)
359
360 case path == "/api/session/packets":
361 mod.showPackets(w, r)
362
363 case path == "/api/session/started-at":
364 mod.showStartedAt(w, r)
365
366 case strings.HasPrefix(path, "/api/session/ble"):
367 mod.showBLE(w, r)
368
369 case strings.HasPrefix(path, "/api/session/hid"):
370 mod.showHID(w, r)
371
372 case strings.HasPrefix(path, "/api/session/wifi"):
373 mod.showWiFi(w, r)
374
375 default:
376 http.Error(w, "Not Found", 404)
377 }

Callers

nothing calls this directly

Calls 15

setSecurityHeadersMethod · 0.95
checkAuthMethod · 0.95
setAuthFailedMethod · 0.95
runSessionCommandMethod · 0.95
showSessionMethod · 0.95
showEnvMethod · 0.95
showGatewayMethod · 0.95
showInterfaceMethod · 0.95
showModulesMethod · 0.95
showLANMethod · 0.95
showOptionsMethod · 0.95
showPacketsMethod · 0.95

Tested by

no test coverage detected