fix(truenas): добавить verify_ssl и request_timeout в Valves, использовать их в запросах
This commit is contained in:
+11
-2
@@ -24,6 +24,12 @@ class Tools:
|
||||
CACHE_TTL: int = Field(
|
||||
default=30, description="Время кэширования в секундах (0 = без кэша)"
|
||||
)
|
||||
verify_ssl: bool = Field(
|
||||
default=False, description="Проверять TLS-сертификат TrueNAS"
|
||||
)
|
||||
request_timeout: int = Field(
|
||||
default=30, description="Таймаут HTTP-запроса в секундах"
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
self.valves = self.Valves()
|
||||
@@ -60,7 +66,10 @@ class Tools:
|
||||
return d
|
||||
try:
|
||||
r = requests.get(
|
||||
f"{self._base}/api/v2.0/{endpoint}", headers=self._headers, timeout=10
|
||||
f"{self._base}/api/v2.0/{endpoint}",
|
||||
headers=self._headers,
|
||||
timeout=self.valves.request_timeout,
|
||||
verify=self.valves.verify_ssl,
|
||||
)
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
@@ -100,7 +109,7 @@ class Tools:
|
||||
r = requests.get(
|
||||
f"{url}/api/v2.0/system/info",
|
||||
headers=self._headers,
|
||||
timeout=10,
|
||||
timeout=self.valves.request_timeout,
|
||||
verify=False,
|
||||
)
|
||||
lines.append(f" Код ответа: {r.status_code}")
|
||||
|
||||
Reference in New Issue
Block a user