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

Method open

internal/pluginhost/stream_bridge.go:34–55  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

32}
33
34func (b *streamBridge) open(ctx context.Context) (string, <-chan pluginapi.ExecutorStreamChunk, func()) {
35 if b == nil {
36 chunks := make(chan pluginapi.ExecutorStreamChunk)
37 close(chunks)
38 return "", chunks, func() {}
39 }
40 id := strconv.FormatUint(b.next.Add(1), 10)
41 chunks := make(chan pluginapi.ExecutorStreamChunk, 16)
42 b.mu.Lock()
43 b.streams[id] = chunks
44 b.mu.Unlock()
45 cleanup := func() {
46 b.close(id, "")
47 }
48 if ctx != nil && ctx.Done() != nil {
49 go func() {
50 <-ctx.Done()
51 b.close(id, ctx.Err().Error())
52 }()
53 }
54 return id, chunks, cleanup
55}
56
57func (b *streamBridge) emit(ctx context.Context, id string, chunk pluginapi.ExecutorStreamChunk) error {
58 if b == nil || id == "" {

Callers 4

ExecuteStreamMethod · 0.45
callHostHTTPDoStreamMethod · 0.45

Calls 2

closeMethod · 0.95
ErrorMethod · 0.45

Tested by 1