MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / format_dns_flow

Function format_dns_flow

mitmproxy/tools/console/common.py:653–723  ·  view source on GitHub ↗
(
    *,
    render_mode: RenderMode,
    focused: bool,
    intercepted: bool,
    marked: str,
    is_replay: str | None,
    op_code: str,
    request_timestamp: float,
    domain: str,
    type: str,
    response_code: str | None,
    response_code_http_equiv: int,
    answer: str | None,
    error_message: str,
    duration: float | None,
)

Source from the content-addressed store, hash-verified

651
652@lru_cache(maxsize=800)
653def format_dns_flow(
654 *,
655 render_mode: RenderMode,
656 focused: bool,
657 intercepted: bool,
658 marked: str,
659 is_replay: str | None,
660 op_code: str,
661 request_timestamp: float,
662 domain: str,
663 type: str,
664 response_code: str | None,
665 response_code_http_equiv: int,
666 answer: str | None,
667 error_message: str,
668 duration: float | None,
669):
670 items = []
671
672 if render_mode in (RenderMode.TABLE, RenderMode.DETAILVIEW):
673 items.append(
674 format_left_indicators(
675 focused=focused, intercepted=intercepted, timestamp=request_timestamp
676 )
677 )
678 else:
679 items.append(fcol(">>" if focused else " ", "focus"))
680
681 scheme_style = "intercepted" if intercepted else SCHEME_STYLES["dns"]
682 t = f"DNS {op_code}"
683 if render_mode is RenderMode.TABLE:
684 t = fixlen(t, 10)
685 items.append(fcol(t, scheme_style))
686 items.append(("weight", 0.5, TruncatedText(domain, colorize_host(domain), "right")))
687 items.append(fcol("(" + fixlen(type, 5)[: len(type)] + ") =", "text"))
688
689 items.append(
690 (
691 "weight",
692 1,
693 (
694 truncated_plain(
695 "..." if answer is None else "?" if not answer else answer, "text"
696 )
697 if error_message is None
698 else truncated_plain(error_message, "error")
699 ),
700 )
701 )
702 status_style = (
703 "intercepted"
704 if intercepted
705 else HTTP_RESPONSE_CODE_STYLE.get(response_code_http_equiv // 100, "code_other")
706 )
707 items.append(
708 fcol(fixlen("" if response_code is None else response_code, 9), status_style)
709 )
710

Callers 1

format_flowFunction · 0.85

Calls 11

format_left_indicatorsFunction · 0.85
fcolFunction · 0.85
fixlenFunction · 0.85
TruncatedTextClass · 0.85
colorize_hostFunction · 0.85
truncated_plainFunction · 0.85
format_durationFunction · 0.85
fixlen_rFunction · 0.85
format_right_indicatorsFunction · 0.85
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…