MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / BindCommand

Method BindCommand

internal/bridge/taskmanager.go:162–182  ·  view source on GitHub ↗

BindCommand associates an injected command ID with a task. This enables reverse lookup from command results to tasks.

(sessionID string, taskID uint32, cmdID string)

Source from the content-addressed store, hash-verified

160// BindCommand associates an injected command ID with a task.
161// This enables reverse lookup from command results to tasks.
162func (tm *TaskManager) BindCommand(sessionID string, taskID uint32, cmdID string) {
163 key := taskKey{sessionID, taskID}
164
165 tm.mu.Lock()
166 defer tm.mu.Unlock()
167
168 task, ok := tm.tasks[key]
169 if !ok {
170 return
171 }
172
173 task.mu.Lock()
174 task.subCmds = append(task.subCmds, cmdID)
175 if task.State == TaskPending {
176 task.State = TaskRunning
177 }
178 task.UpdatedAt = time.Now()
179 task.mu.Unlock()
180
181 tm.subIndex[cmdID] = task
182}
183
184// LookupByCommand returns the task associated with a command ID, or nil.
185func (tm *TaskManager) LookupByCommand(cmdID string) *Task {

Callers 8

TestTask_LifecycleFunction · 0.95
TestTask_FailStateFunction · 0.95
TestTask_LookupByCommandFunction · 0.95
enqueueAndAwaitFunction · 0.80
enqueueToolActionFunction · 0.80

Calls

no outgoing calls

Tested by 6

TestTask_LifecycleFunction · 0.76
TestTask_FailStateFunction · 0.76
TestTask_LookupByCommandFunction · 0.76