MCPcopy
hub / github.com/bettercap/bettercap / showSession

Method showSession

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

Source from the content-addressed store, hash-verified

98}
99
100func (mod *RestAPI) showSession(w http.ResponseWriter, r *http.Request) {
101 if mod.replaying {
102 if !mod.record.Session.Over() {
103 from := mod.record.Session.Index() - 1
104 q := r.URL.Query()
105 vals := q["from"]
106 if len(vals) > 0 {
107 if n, err := strconv.Atoi(vals[0]); err == nil {
108 from = n
109 }
110 }
111 mod.record.Session.SetFrom(from)
112
113 mod.Debug("replaying session %d of %d from %s",
114 mod.record.Session.Index(),
115 mod.record.Session.Frames(),
116 mod.recordFileName)
117
118 mod.State.Store("rec_frames", mod.record.Session.Frames())
119 mod.State.Store("rec_cur_frame", mod.record.Session.Index())
120
121 buf := mod.record.Session.Next()
122 if frame, err := mod.patchFrame(buf); err != nil {
123 mod.Error("%v", err)
124 } else {
125 mod.toJSON(w, frame)
126 return
127 }
128 } else {
129 mod.stopReplay()
130 }
131 }
132
133 mod.toJSON(w, mod.Session)
134}
135
136func (mod *RestAPI) showBLE(w http.ResponseWriter, r *http.Request) {
137 params := mux.Vars(r)

Callers 1

sessionRouteMethod · 0.95

Calls 5

patchFrameMethod · 0.95
toJSONMethod · 0.95
stopReplayMethod · 0.95
DebugMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected