MCPcopy
hub / github.com/mitmproxy/mitmproxy / inject_event

Method inject_event

mitmproxy/addons/proxyserver.py:315–333  ·  view source on GitHub ↗
(self, event: events.MessageInjected)

Source from the content-addressed store, hash-verified

313 return [addr for server in self.servers for addr in server.listen_addrs]
314
315 def inject_event(self, event: events.MessageInjected):
316 connection_id: str | tuple
317 if event.flow.client_conn.transport_protocol != "udp":
318 connection_id = event.flow.client_conn.id
319 else: # pragma: no cover
320 # temporary workaround: for UDP we don't have persistent client IDs yet.
321 connection_id = (
322 event.flow.client_conn.peername,
323 event.flow.client_conn.sockname,
324 )
325 if connection_id not in self.connections:
326 raise ValueError("Flow is not from a live connection.")
327
328 asyncio_utils.create_task(
329 self.connections[connection_id].server_event(event),
330 name=f"inject_event",
331 keep_ref=True,
332 client=event.flow.client_conn.peername,
333 )
334
335 @command.command("inject.websocket")
336 def inject_websocket(

Callers 3

inject_websocketMethod · 0.95
inject_tcpMethod · 0.95
inject_udpMethod · 0.95

Calls 1

server_eventMethod · 0.80

Tested by

no test coverage detected