| 151 | self.data = https_records.pack(record) |
| 152 | |
| 153 | def _data_json(self) -> str | HTTPSRecordJSON: |
| 154 | try: |
| 155 | match self.type: |
| 156 | case types.A: |
| 157 | return str(self.ipv4_address) |
| 158 | case types.AAAA: |
| 159 | return str(self.ipv6_address) |
| 160 | case types.NS | types.CNAME | types.PTR: |
| 161 | return self.domain_name |
| 162 | case types.TXT: |
| 163 | return self.text |
| 164 | case types.HTTPS: |
| 165 | return https_records.unpack(self.data).to_json() |
| 166 | case _: |
| 167 | return f"0x{self.data.hex()}" |
| 168 | except Exception: |
| 169 | return f"0x{self.data.hex()} (invalid {types.to_str(self.type)} data)" |
| 170 | |
| 171 | def to_json(self) -> dict[str, str | int | HTTPSRecordJSON]: |
| 172 | """ |