Skip to content

Commit

Permalink
stop calling websocket_local_ip (#14385)
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo authored Aug 30, 2024
1 parent 5dcffa7 commit 7323f89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/middlewared/middlewared/plugins/apps/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,17 @@ def query(self, app, filters, options):
return filter_list([], filters, options)

extra = options.get('extra', {})
host_ip = extra.get('host_ip')
if not host_ip:
try:
if app.origin.is_tcp_ip_family:
host_ip = app.origin.loc_addr
except AttributeError:
pass

retrieve_app_schema = extra.get('include_app_schema', False)
kwargs = {
'host_ip': extra.get('host_ip') or self.middleware.call_sync('interface.websocket_local_ip', app=app),
'host_ip': host_ip,
'retrieve_config': extra.get('retrieve_config', False),
'image_update_cache': self.middleware.call_sync('app.image.op.get_update_cache', True),
}
Expand Down
19 changes: 10 additions & 9 deletions src/middlewared/middlewared/plugins/vm/vm_display_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ipaddress
from socket import AF_INET6

from middlewared.schema import accepts, Dict, Int, List, Ref, returns, Str
from middlewared.schema import accepts, Dict, Int, List, returns, Str
from middlewared.service import pass_app, private, Service

from .devices import DISPLAY
Expand Down Expand Up @@ -94,13 +94,14 @@ async def get_display_web_uri(self, app, id_, host, options):
"""
uri_data = {'error': None, 'uri': None}
protocol = options['protocol'].lower()
host = host or await self.middleware.call('interface.websocket_local_ip', app=app)
try:
ipaddress.IPv6Address(host)
except ipaddress.AddressValueError:
pass
else:
host = f'[{host}]'
if not host:
try:
if app.origin.is_tcp_ip_family and (_h := app.origin.loc_addr):
host = _h
if app.origin.family == AF_INET6:
host = f'[{_h}]'
except AttributeError:
pass

if display_devices := await self.get_display_devices(id_):
for device in map(lambda d: DISPLAY(d, middleware=self.middleware), display_devices):
Expand Down

0 comments on commit 7323f89

Please sign in to comment.