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

Method Create

internal/bridge/taskmanager.go:95–117  ·  view source on GitHub ↗

Create registers a new task in Pending state. If a task with the same sessionID+taskID already exists, it is returned as-is.

(sessionID string, taskID uint32, module string)

Source from the content-addressed store, hash-verified

93// Create registers a new task in Pending state.
94// If a task with the same sessionID+taskID already exists, it is returned as-is.
95func (tm *TaskManager) Create(sessionID string, taskID uint32, module string) *Task {
96 key := taskKey{sessionID, taskID}
97 now := time.Now()
98
99 tm.mu.Lock()
100 defer tm.mu.Unlock()
101
102 if existing, ok := tm.tasks[key]; ok {
103 return existing
104 }
105
106 task := &Task{
107 ID: taskID,
108 SessionID: sessionID,
109 Module: module,
110 State: TaskPending,
111 CreatedAt: now,
112 UpdatedAt: now,
113 resultCh: make(chan *sessions.CommandResult, taskResultBufferSize),
114 }
115 tm.tasks[key] = task
116 return task
117}
118
119// Get returns the task for the given sessionID+taskID, or nil.
120func (tm *TaskManager) Get(sessionID string, taskID uint32) *Task {

Calls

no outgoing calls