mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-09 22:13:43 +08:00
a531afd02a
Expose pairing readiness and coordinate adapter hand-offs with Android Auto. Show app pairings separately, support individual removal, and improve pairing controls on both comma screens. Add Galaxy companion endpoints and web asset manifests, preserve the plain camera look, and fix headless speed-limit shapes.
27 lines
887 B
Python
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 = 3.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()
|