MCPcopy
hub / github.com/mitmproxy/mitmproxy / to_json

Method to_json

mitmproxy/dns.py:511–534  ·  view source on GitHub ↗

Converts the message into json for mitmweb. Sync with web/src/flow.ts.

(self)

Source from the content-addressed store, hash-verified

509 return bytes(data)
510
511 def to_json(self) -> dict:
512 """
513 Converts the message into json for mitmweb.
514 Sync with web/src/flow.ts.
515 """
516 ret = {
517 "id": self.id,
518 "query": self.query,
519 "op_code": op_codes.to_str(self.op_code),
520 "authoritative_answer": self.authoritative_answer,
521 "truncation": self.truncation,
522 "recursion_desired": self.recursion_desired,
523 "recursion_available": self.recursion_available,
524 "response_code": response_codes.to_str(self.response_code),
525 "status_code": response_codes.http_equiv_status_code(self.response_code),
526 "questions": [question.to_json() for question in self.questions],
527 "answers": [rr.to_json() for rr in self.answers],
528 "authorities": [rr.to_json() for rr in self.authorities],
529 "additionals": [rr.to_json() for rr in self.additionals],
530 "size": self.size,
531 }
532 if self.timestamp:
533 ret["timestamp"] = self.timestamp
534 return ret
535
536 @classmethod
537 def from_json(cls, data: Any) -> DNSMessage:

Callers

nothing calls this directly

Calls 1

to_jsonMethod · 0.45

Tested by

no test coverage detected