| 391 | ) |
| 392 | |
| 393 | def client_conf(self) -> str | None: |
| 394 | if not self._servers: |
| 395 | return None |
| 396 | host = ( |
| 397 | self.mode.listen_host(ctx.options.listen_host) |
| 398 | or local_ip.get_local_ip() |
| 399 | or local_ip.get_local_ip6() |
| 400 | ) |
| 401 | port = self.mode.listen_port(ctx.options.listen_port) |
| 402 | return textwrap.dedent( |
| 403 | f""" |
| 404 | [Interface] |
| 405 | PrivateKey = {self.client_key} |
| 406 | Address = 10.0.0.1/32 |
| 407 | DNS = 10.0.0.53 |
| 408 | |
| 409 | [Peer] |
| 410 | PublicKey = {mitmproxy_rs.wireguard.pubkey(self.server_key)} |
| 411 | AllowedIPs = 0.0.0.0/0 |
| 412 | Endpoint = {host}:{port} |
| 413 | """ |
| 414 | ).strip() |
| 415 | |
| 416 | def to_json(self) -> dict: |
| 417 | return {"wireguard_conf": self.client_conf(), **super().to_json()} |