Add improved Ziti status check
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# checks.py
|
# checks.py
|
||||||
import socket
|
import socket
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
|
||||||
|
|
||||||
class SystemChecks:
|
class SystemChecks:
|
||||||
@@ -16,11 +18,21 @@ class SystemChecks:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def check_ziti_status(self):
|
def check_ziti_status(self):
|
||||||
"""Probes the configured Ziti target endpoint."""
|
"""Makes an HTTP request to the configured address."""
|
||||||
if not self.ziti_target:
|
if not self.ziti_target:
|
||||||
return False
|
return False
|
||||||
host, port = self.ziti_target
|
|
||||||
return self._tcp_ping(host, int(port), timeout=1.0)
|
try:
|
||||||
|
request = urllib.request.Request(
|
||||||
|
self.ziti_target,
|
||||||
|
method="GET",
|
||||||
|
)
|
||||||
|
|
||||||
|
with urllib.request.urlopen(request, timeout=2.0) as response:
|
||||||
|
return 200 <= response.status < 300
|
||||||
|
|
||||||
|
except (urllib.error.URLError, TimeoutError, OSError):
|
||||||
|
return False
|
||||||
|
|
||||||
def _tcp_ping(self, host, port, timeout=1):
|
def _tcp_ping(self, host, port, timeout=1):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user