Skip to content

Commit

Permalink
Disable IPV6 in the august integration (#98003)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 25, 2023
1 parent 2e643c0 commit ece7ec6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
8 changes: 3 additions & 5 deletions homeassistant/components/august/__init__.py
Expand Up @@ -25,13 +25,14 @@
ConfigEntryNotReady,
HomeAssistantError,
)
from homeassistant.helpers import aiohttp_client, device_registry as dr, discovery_flow
from homeassistant.helpers import device_registry as dr, discovery_flow

from .activity import ActivityStream
from .const import CONF_BRAND, DOMAIN, MIN_TIME_BETWEEN_DETAIL_UPDATES, PLATFORMS
from .exceptions import CannotConnect, InvalidAuth, RequireValidation
from .gateway import AugustGateway
from .subscriber import AugustSubscriberMixin
from .util import async_create_august_clientsession

_LOGGER = logging.getLogger(__name__)

Expand All @@ -46,10 +47,7 @@

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up August from a config entry."""
# Create an aiohttp session instead of using the default one since the
# default one is likely to trigger august's WAF if another integration
# is also using Cloudflare
session = aiohttp_client.async_create_clientsession(hass)
session = async_create_august_clientsession(hass)
august_gateway = AugustGateway(hass, session)

try:
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/august/config_flow.py
Expand Up @@ -13,7 +13,6 @@
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import aiohttp_client

from .const import (
CONF_ACCESS_TOKEN_CACHE_FILE,
Expand All @@ -26,6 +25,7 @@
)
from .exceptions import CannotConnect, InvalidAuth, RequireValidation
from .gateway import AugustGateway
from .util import async_create_august_clientsession

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -159,10 +159,7 @@ def _async_get_gateway(self) -> AugustGateway:
"""Set up the gateway."""
if self._august_gateway is not None:
return self._august_gateway
# Create an aiohttp session instead of using the default one since the
# default one is likely to trigger august's WAF if another integration
# is also using Cloudflare
self._aiohttp_session = aiohttp_client.async_create_clientsession(self.hass)
self._aiohttp_session = async_create_august_clientsession(self.hass)
self._august_gateway = AugustGateway(self.hass, self._aiohttp_session)
return self._august_gateway

Expand Down
24 changes: 24 additions & 0 deletions homeassistant/components/august/util.py
@@ -0,0 +1,24 @@
"""August util functions."""

import socket

import aiohttp

from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import aiohttp_client


@callback
def async_create_august_clientsession(hass: HomeAssistant) -> aiohttp.ClientSession:
"""Create an aiohttp session for the august integration."""
# Create an aiohttp session instead of using the default one since the
# default one is likely to trigger august's WAF if another integration
# is also using Cloudflare
#
# The family is set to AF_INET because IPv6 keeps coming up as an issue
# see https://github.com/home-assistant/core/issues/97146
#
# When https://github.com/aio-libs/aiohttp/issues/4451 is implemented
# we can allow IPv6 again
#
return aiohttp_client.async_create_clientsession(hass, family=socket.AF_INET)

0 comments on commit ece7ec6

Please sign in to comment.