mirror of
https://github.com/home-assistant/core.git
synced 2026-07-10 00:05:13 +01:00
Store recovery HTTP config with the full trusted proxy network (#176075)
This commit is contained in:
@@ -725,8 +725,11 @@ async def start_http_server_and_save_config(
|
||||
)
|
||||
|
||||
if CONF_TRUSTED_PROXIES in conf:
|
||||
# Store the full network (address and prefix) so the recovery config
|
||||
# round-trips losslessly; ``network_address`` alone drops the netmask
|
||||
# and would narrow e.g. 10.0.0.0/24 to a single host.
|
||||
conf[CONF_TRUSTED_PROXIES] = [
|
||||
str(cast(IPv4Network | IPv6Network, ip).network_address)
|
||||
str(cast(IPv4Network | IPv6Network, ip))
|
||||
for ip in conf[CONF_TRUSTED_PROXIES]
|
||||
]
|
||||
|
||||
|
||||
@@ -490,7 +490,7 @@ async def test_storing_config(
|
||||
config = {
|
||||
http.CONF_SERVER_PORT: unused_tcp_port_factory(),
|
||||
"use_x_forwarded_for": True,
|
||||
"trusted_proxies": ["192.168.1.100"],
|
||||
"trusted_proxies": ["192.168.1.100", "10.0.0.0/24"],
|
||||
}
|
||||
|
||||
assert await async_setup_component(hass, http.DOMAIN, {http.DOMAIN: config})
|
||||
@@ -501,7 +501,9 @@ async def test_storing_config(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
restored = await http.async_get_last_config(hass)
|
||||
restored["trusted_proxies"][0] = ip_network(restored["trusted_proxies"][0])
|
||||
restored["trusted_proxies"] = [
|
||||
ip_network(proxy) for proxy in restored["trusted_proxies"]
|
||||
]
|
||||
|
||||
assert restored == http.HTTP_SCHEMA(config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user