0.4.2: show connectable VNC target (host:port) instead of the 0.0.0.0 bind address

This commit is contained in:
Claw committed 2026-11-17 20:47:21 +01:00
1 parent bd5ae7e7bc
commit 3c2ee78944
4 files changed
+53 -2

No files matched your search

+21
View File
@@ -826,6 +826,27 @@ function vmm_delete_data_file(string $dir, string $name): array
: ['ok' => false, 'error' => 'cannot delete']; : ['ok' => false, 'error' => 'cannot delete'];
} }
/**
* Turn a bhyve VNC bind address ("0.0.0.0:5901") into something a human can
* actually connect to. 0.0.0.0 is a listen address, not a destination.
*/
function vmm_vnc_connect(string $bind): string
{
$bind = trim($bind);
if ($bind === '' || $bind === '-') {
return '';
}
[$host, $port] = array_pad(explode(':', $bind, 2), 2, '');
$port = (int)$port;
if ($port <= 0) {
return '';
}
if ($host === '0.0.0.0' || $host === '' || $host === '*') {
$host = trim((string)@shell_exec('hostname -f 2>/dev/null')) ?: (gethostname() ?: 'localhost');
}
return $host . ':' . $port;
}
function vmm_vm_conf_path(string $name): string function vmm_vm_conf_path(string $name): string
{ {
$dir = vmm_data_dir(''); $dir = vmm_data_dir('');
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"appname": "VM Manager", "appname": "VM Manager",
"version": "0.4.1", "version": "0.4.2",
"rootfolder": "/mnt/Daten/extensions/vmmngr", "rootfolder": "/mnt/Daten/extensions/vmmngr",
"vm_source": "auto", "vm_source": "auto",
"bridges": ["ix0bridge"], "bridges": ["ix0bridge"],
+30
View File
@@ -133,6 +133,36 @@ vmm_nav('dashboard');
</tbody> </tbody>
</table> </table>
<?php
$vncBind = '';
foreach (($info['sections']['console-ports'] ?? []) as $b) {
if (!empty($b['data']['vnc'])) {
$vncBind = (string)$b['data']['vnc'];
}
}
$vncTarget = vmm_vnc_connect($vncBind);
?>
<?php if ($vncTarget !== ''): ?>
<table class="area_data_settings" style="width:100%;border-collapse:collapse;">
<colgroup><col class="area_data_settings_col_tag"><col class="area_data_settings_col_data"></colgroup>
<thead><?php html_separator2(); html_titleline2(gettext('Console access'), 2); ?></thead>
<tbody>
<tr>
<td class="celltag">VNC</td>
<td class="celldata">
<a class="formbtn" href="vnc://<?=vmm_h($vncTarget);?>">vnc://<?=vmm_h($vncTarget);?></a>
<span class="vmm-mono" style="margin-left:8px;"><?=gettext('bind');?>: <?=vmm_h($vncBind);?></span>
<div style="opacity:.75;margin-top:4px;"><?=gettext('0.0.0.0 is the listening address - connect to the host name above. No password is set.');?></div>
</td>
</tr>
<tr>
<td class="celltag"><?=gettext('Serial');?></td>
<td class="celldata vmm-mono">cu -l /dev/nmdm-<?=vmm_h($name);?>.1B</td>
</tr>
</tbody>
</table>
<?php endif; ?>
<?php <?php
$attached = vmm_attached_isos($name); $attached = vmm_attached_isos($name);
$isos = vmm_file_list(vmm_data_dir('.iso'), ['iso']); $isos = vmm_file_list(vmm_data_dir('.iso'), ['iso']);
+1 -1
View File
@@ -1 +1 @@
0.4.1 0.4.2