mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
fix wsrelay connection in ipv6 environments
This commit is contained in:
@@ -3,6 +3,8 @@ import logging
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import client_exceptions
|
from aiohttp import client_exceptions
|
||||||
import aioredis
|
import aioredis
|
||||||
@@ -71,7 +73,16 @@ class WebsocketRelayConnection:
|
|||||||
if not self.channel_layer:
|
if not self.channel_layer:
|
||||||
self.channel_layer = get_channel_layer()
|
self.channel_layer = get_channel_layer()
|
||||||
|
|
||||||
uri = f"{self.protocol}://{self.remote_host}:{self.remote_port}/websocket/relay/"
|
# figure out if what we have is an ipaddress, IPv6 Addresses must have brackets added for uri
|
||||||
|
uri_hostname = self.remote_host
|
||||||
|
try:
|
||||||
|
# Throws ValueError if self.remote_host is a hostname like example.com, not an IPv4 or IPv6 ip address
|
||||||
|
if isinstance(ipaddress.ip_address(uri_hostname), ipaddress.IPv6Address):
|
||||||
|
uri_hostname = f"[{uri_hostname}]"
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
uri = f"{self.protocol}://{uri_hostname}:{self.remote_port}/websocket/relay/"
|
||||||
timeout = aiohttp.ClientTimeout(total=10)
|
timeout = aiohttp.ClientTimeout(total=10)
|
||||||
|
|
||||||
secret_val = WebsocketSecretAuthHelper.construct_secret()
|
secret_val = WebsocketSecretAuthHelper.construct_secret()
|
||||||
|
|||||||
Reference in New Issue
Block a user