mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-18 14:53:51 +08:00
LogReader: fix issue when your dns resolves all requests (#34089)
* terrible :( * keep this spacing
This commit is contained in:
@@ -5,12 +5,15 @@ from urllib.parse import urlparse
|
||||
from openpilot.tools.lib.url_file import URLFile
|
||||
|
||||
DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")
|
||||
LOCAL_IPS = ["10.", "192.168.", *[f"172.{i}" for i in range(16, 32)]]
|
||||
|
||||
|
||||
def internal_source_available(url=DATA_ENDPOINT):
|
||||
try:
|
||||
hostname = urlparse(url).hostname
|
||||
port = urlparse(url).port or 80
|
||||
if not socket.gethostbyname(hostname).startswith(LOCAL_IPS):
|
||||
return False
|
||||
with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s:
|
||||
s.settimeout(0.5)
|
||||
s.connect((hostname, port))
|
||||
|
||||
Reference in New Issue
Block a user