moduleContext builds a ModuleContext that gives modules access to bridge capabilities without exposing the Bridge struct directly.
()
| 241 | // moduleContext builds a ModuleContext that gives modules access to |
| 242 | // bridge capabilities without exposing the Bridge struct directly. |
| 243 | func (b *Bridge) moduleContext() ModuleContext { |
| 244 | return ModuleContext{ |
| 245 | ListenerID: b.listenerID, |
| 246 | SendSpite: func(sessionID string, taskID uint32, spite *implantpb.Spite) error { |
| 247 | return b.sendSpite(&clientpb.SpiteResponse{ |
| 248 | ListenerId: b.listenerID, |
| 249 | SessionId: sessionID, |
| 250 | TaskId: taskID, |
| 251 | Spite: spite, |
| 252 | }) |
| 253 | }, |
| 254 | Tasks: b.taskManager, |
| 255 | TappingGet: func(sessionID string) (uint32, bool) { |
| 256 | v, ok := b.tappingTask.Load(sessionID) |
| 257 | if !ok { |
| 258 | return 0, false |
| 259 | } |
| 260 | return v.(uint32), true |
| 261 | }, |
| 262 | TappingSet: func(sessionID string, taskID uint32) { |
| 263 | b.tappingTask.Store(sessionID, taskID) |
| 264 | }, |
| 265 | TappingDel: func(sessionID string) { |
| 266 | b.tappingTask.Delete(sessionID) |
| 267 | }, |
| 268 | WaitForSession: b.waitForSession, |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // sessionContext returns a gRPC context with session_id and listener metadata. |
| 273 | func (b *Bridge) sessionContext(sessionID string) context.Context { |