Skip to content

Commit

Permalink
fix client with IP addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-mc1 committed Feb 8, 2024
1 parent 8c8dcfc commit 5520e14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 0 additions & 2 deletions custom_components/qbittorrent_alt/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def __init__(
)

async def _async_update_data(self) -> dict[str, Any]:
if self.client.is_closed():
self.client._http = aiohttp.ClientSession()
try:
main_data = await self.client.sync.maindata()
downloading = 0
Expand Down
16 changes: 9 additions & 7 deletions custom_components/qbittorrent_alt/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ssl

from aiohttp import ClientSession, CookieJar
from aioqbt.api.types import TorrentInfo
from aioqbt.client import APIClient, create_client
from homeassistant.const import STATE_IDLE
Expand All @@ -11,16 +12,17 @@ async def setup_client(
url: str, username: str, password: str, verify_ssl: bool
) -> APIClient:
if verify_ssl:
ssl_contex = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
else:
ssl_contex = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT, verify_mode=ssl.CERT_NONE)
ssl_contex.check_hostname = False
ssl_contex.verify_mode = ssl.CERT_NONE
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT, verify_mode=ssl.CERT_NONE)
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
client_session = ClientSession(cookie_jar=CookieJar(unsafe=True))
client = await create_client(
url, username=username, password=password, ssl=ssl_contex
url, username=username, password=password, ssl=ssl_context, http=client_session
)
async with client:
await client.app.version()
client._http_owner = True # Let aioqbt manage the ClientSession
await client.app.version()
return client


Expand Down

0 comments on commit 5520e14

Please sign in to comment.