0.4.2: show connectable VNC target (host:port) instead of the 0.0.0.0 bind address
This commit is contained in:
1 parent
bd5ae7e7bc
commit
3c2ee78944
4 files changed
+53
-2
No files matched your search
@@ -826,6 +826,27 @@ function vmm_delete_data_file(string $dir, string $name): array
|
||||
: ['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
|
||||
{
|
||||
$dir = vmm_data_dir('');
|
||||
|
||||
Reference in new issue
Block a user