mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-12-03 18:33:43 +08:00
p2p: set IPV6_FREEBIND for tentative nan_data0 and fallback Direct passphrase
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user