Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-130886 / 25.04 / stop calling websocket_local_ip #14385

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, below you handled IPv6. Do we need to do so here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonicaj do we need to put ipv6 address in brackets here for host_ip key in apps?

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
Loading