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

Function cliproxyHostCall

internal/pluginhost/host_callbacks_unix.go:22–58  ·  view source on GitHub ↗

export cliproxyHostCall

(hostCtx unsafe.Pointer, method *C.char, request *C.uint8_t, requestLen C.size_t, response *C.cliproxy_buffer)

Source from the content-addressed store, hash-verified

20
21//export cliproxyHostCall
22func cliproxyHostCall(hostCtx unsafe.Pointer, method *C.char, request *C.uint8_t, requestLen C.size_t, response *C.cliproxy_buffer) C.int {
23 if response != nil {
24 response.ptr = nil
25 response.len = 0
26 }
27 if hostCtx == nil || method == nil {
28 return 1
29 }
30 id := uintptr(*(*C.uintptr_t)(hostCtx))
31 rawHost, okHost := hostCallbackEntries.Load(id)
32 if !okHost {
33 return 1
34 }
35 entry, okHost := rawHost.(dynamicHostCallbackEntry)
36 if !okHost || entry.host == nil {
37 return 1
38 }
39 var requestBytes []byte
40 if request != nil && requestLen > 0 {
41 requestBytes = C.GoBytes(unsafe.Pointer(request), C.int(requestLen))
42 }
43 ctx := withHostCallbackPluginID(context.Background(), entry.pluginID)
44 resp, errCall := entry.host.callFromPlugin(ctx, C.GoString(method), requestBytes)
45 if errCall != nil {
46 resp = marshalRPCError("host_call_failed", errCall.Error())
47 }
48 if len(resp) == 0 || response == nil {
49 return 0
50 }
51 ptr := C.CBytes(resp)
52 if ptr == nil {
53 return 1
54 }
55 response.ptr = ptr
56 response.len = C.size_t(len(resp))
57 return 0
58}
59
60//export cliproxyHostFree
61func cliproxyHostFree(ptr unsafe.Pointer, len C.size_t) {

Callers

nothing calls this directly

Calls 5

withHostCallbackPluginIDFunction · 0.85
marshalRPCErrorFunction · 0.85
callFromPluginMethod · 0.80
LoadMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected