MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / HTTPSRecord

Class HTTPSRecord

mitmproxy/net/dns/https_records.py:39–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38@dataclass
39class HTTPSRecord:
40 priority: int
41 target_name: str
42 params: dict[int, bytes]
43
44 def __repr__(self):
45 return str(self.to_json())
46
47 def to_json(self) -> HTTPSRecordJSON:
48 ret: HTTPSRecordJSON = {
49 "target_name": self.target_name,
50 "priority": self.priority,
51 }
52 typ: str | int
53 for typ, val in self.params.items():
54 try:
55 typ = SVCParamKeys(typ).name.lower()
56 except ValueError:
57 pass
58 ret[typ] = strutils.bytes_to_escaped_str(val)
59 return ret
60
61 @classmethod
62 def from_json(cls, data: HTTPSRecordJSON) -> Self:
63 target_name = data.pop("target_name")
64 assert isinstance(target_name, str)
65 priority = data.pop("priority")
66 assert isinstance(priority, int)
67 params: dict[int, bytes] = {}
68 for k, v in data.items():
69 if isinstance(k, str):
70 k = SVCParamKeys[k.upper()].value
71 assert isinstance(v, str)
72 params[k] = strutils.escaped_str_to_bytes(v)
73 return cls(target_name=target_name, priority=priority, params=params)
74
75
76def _unpack_params(data: bytes, offset: int) -> dict[int, bytes]:

Callers 1

unpackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…