Skip to content

Commit

Permalink
NAS-128845 / 24.10 / Do not render all IPv4 addresses in Web UI URLs …
Browse files Browse the repository at this point in the history
…list if :: is in the listen address list, but `0.0.0.0` is not (#14154)

* Refresh Web UI URLs displayed in CLI on settings update

* Do not render all IPv4 addresses in Web UI URLs list if `::` is in the listen address list, but `0.0.0.0` is not

* Address feedback
  • Loading branch information
themylogin authored Aug 8, 2024
1 parent b9d3e8d commit 0fd70a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
12 changes: 1 addition & 11 deletions src/middlewared/middlewared/plugins/network_/global_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import ipaddress
import psutil
import contextlib
import signal

import middlewared.sqlalchemy as sa
from middlewared.service import ConfigService, private
Expand Down Expand Up @@ -345,14 +342,7 @@ async def do_update(self, data):
except Exception:
self.logger.warning('Failed to generate resolv.conf on standby storage controller', exc_info=True)

def reload_cli():
for process in psutil.process_iter(['pid', 'cmdline']):
cmdline = process.cmdline()
if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli':
with contextlib.suppress(Exception):
process.send_signal(signal.SIGUSR1)

await self.middleware.run_in_thread(reload_cli)
await self.middleware.call('system.reload_cli')

# default gateways changed
ipv4gw_changed = new_config['ipv4gateway'] != config['ipv4gateway']
Expand Down
16 changes: 16 additions & 0 deletions src/middlewared/middlewared/plugins/system/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import contextlib
import signal

import psutil

from middlewared.service import Service, private


class SystemService(Service):
@private
def reload_cli(self):
for process in psutil.process_iter(['pid', 'cmdline']):
cmdline = process.cmdline()
if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli':
with contextlib.suppress(Exception):
process.send_signal(signal.SIGUSR1)
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/system_general/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def get_ui_urls(self):
if https_port != 443:
https_url += f':{https_port}'

if all_ip4 or all_ip6:
if (i['type'] == 'INET' and all_ip4) or (i['type'] == 'INET6' and all_ip6):
urls.add(http_url)
if https_url:
urls.add(https_url)
Expand Down
13 changes: 9 additions & 4 deletions src/middlewared/middlewared/plugins/system_general/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ async def do_update(self, data):
verrors = await self.validate_general_settings(new_config, 'general_settings_update')
verrors.check()

keys = new_config.keys()
for key in list(keys):
db_config = new_config.copy()
for key in list(new_config.keys()):
if key.startswith('ui_'):
new_config['gui' + key[3:]] = new_config.pop(key)
db_config['gui' + key[3:]] = db_config.pop(key)

await self.middleware.call(
'datastore.update',
self._config.datastore,
config['id'],
new_config,
db_config,
{'prefix': 'stg_'}
)

Expand Down Expand Up @@ -289,6 +289,11 @@ async def do_update(self, data):
if ui_restart_delay is not None:
await self.middleware.call('system.general.ui_restart', ui_restart_delay)

for key in ('ui_port', 'ui_httpsport', 'ui_httpsredirect', 'ui_address', 'ui_v6address'):
if config[key] != new_config[key]:
await self.middleware.call('system.reload_cli')
break

return await self.config()

@private
Expand Down

0 comments on commit 0fd70a7

Please sign in to comment.