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

Method _start

mitmproxy/proxy/mode_servers.py:346–379  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

344 return layers.modes.TransparentProxy(context)
345
346 async def _start(self) -> None:
347 if self.mode.data:
348 conf_path = Path(self.mode.data).expanduser()
349 else:
350 conf_path = Path(ctx.options.confdir).expanduser() / "wireguard.conf"
351
352 if not conf_path.exists():
353 conf_path.parent.mkdir(parents=True, exist_ok=True)
354 conf_path.write_text(
355 json.dumps(
356 {
357 "server_key": mitmproxy_rs.wireguard.genkey(),
358 "client_key": mitmproxy_rs.wireguard.genkey(),
359 },
360 indent=4,
361 )
362 )
363
364 try:
365 c = json.loads(conf_path.read_text())
366 self.server_key = c["server_key"]
367 self.client_key = c["client_key"]
368 except Exception as e:
369 raise ValueError(f"Invalid configuration file ({conf_path}): {e}") from e
370
371 # error early on invalid keys
372 self.pubkey = mitmproxy_rs.wireguard.pubkey(self.client_key)
373 _ = mitmproxy_rs.wireguard.pubkey(self.server_key)
374
375 await super()._start()
376
377 conf = self.client_conf()
378 assert conf
379 logger.info("-" * 60 + "\n" + conf + "\n" + "-" * 60)
380
381 async def start_udp_based_server(
382 self, host, port

Callers

nothing calls this directly

Calls 6

client_confMethod · 0.95
PathClass · 0.85
dumpsMethod · 0.80
loadsMethod · 0.80
infoMethod · 0.80
_startMethod · 0.45

Tested by

no test coverage detected