Files
StarPilot/openpilot/starpilot/system/android_auto/source_verifier.py
T
firestar5683 a82935f326 User interfaces and Android Auto
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: pharmacomaniac <blittle65@gmail.com>

Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

27 lines
887 B
Python

"""Fail-closed daemon check of a Galaxy-minted pairing source over loopback."""
from __future__ import annotations
import http.client
import re
SOURCE_ID = re.compile(r'[0-9a-f]{64}\Z')
class GalaxySourceVerifier:
def __init__(self, host: str = '127.0.0.1', port: int = 8082, timeout: float = 1.0):
self.host, self.port, self.timeout = host, port, timeout
def valid(self, source: str) -> bool:
if not isinstance(source, str) or not SOURCE_ID.fullmatch(source):
return False
connection = http.client.HTTPConnection(self.host, self.port, timeout=self.timeout)
try:
connection.request('GET', '/api/android-auto/source/' + source)
response = connection.getresponse()
response.read(512)
return response.status == 200
except (OSError, TimeoutError, http.client.HTTPException):
return False
finally:
connection.close()