diff --git a/openpilot/sunnypilot/system/p2p/server.py b/openpilot/sunnypilot/system/p2p/server.py index d32fb708e9..fe90bd115b 100644 --- a/openpilot/sunnypilot/system/p2p/server.py +++ b/openpilot/sunnypilot/system/p2p/server.py @@ -127,6 +127,11 @@ class P2pTlsServer: except OSError: pass if family == socket.AF_INET6: + ipv6_freebind = getattr(socket, "IPV6_FREEBIND", 78) + try: + sock.setsockopt(socket.IPPROTO_IPV6, ipv6_freebind, 1) + except OSError: + pass scope_id = socket.if_nametoindex(self._bind_interface) if self._bind_interface else 0 sock.bind((host_clean, self._port, 0, scope_id)) else: diff --git a/openpilot/sunnypilot/system/p2p/transports.py b/openpilot/sunnypilot/system/p2p/transports.py index 8675633283..69faa39902 100644 --- a/openpilot/sunnypilot/system/p2p/transports.py +++ b/openpilot/sunnypilot/system/p2p/transports.py @@ -95,6 +95,9 @@ class WifiDirectTransport: kv = dict(line.split("=", 1) for line in status_out.splitlines() if "=" in line) ssid = kv.get("ssid", f"DIRECT-{session_id[:6]}") passphrase = subprocess.run(["wpa_cli", "-i", iface, "p2p_get_passphrase"], capture_output=True, text=True, timeout=5, check=False).stdout.strip() + if not passphrase or passphrase == "FAIL": + passphrase = secrets.token_urlsafe(12) + subprocess.run(["wpa_cli", "-i", iface, "set_network", "0", "psk", f'"{passphrase}"'], capture_output=True, text=True, timeout=5, check=False) subprocess.run(["sudo", "ip", "addr", "replace", f"{P2P_DIRECT_IP}/24", "dev", iface], check=False, timeout=5) subprocess.run(["sudo", "ip", "link", "set", iface, "up"], check=False, timeout=5)