mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-03 07:14:34 +00:00
Add support for raw IPv6 addresses in VNC & libvirt URIs
Support vnc://[x:y:z:]:5901/ for raw IPv6 addresses in URIs, and qemu+ssh://root@[x:y:x:]:22/ for raw IPv6 addresses in libvirt URIs
This commit is contained in:
parent
c1af3ab0cc
commit
7ab88ea179
@ -197,6 +197,7 @@ virt_viewer_session_vnc_open_uri(VirtViewerSession* session,
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
xmlURIPtr uri = NULL;
|
||||
gchar *portstr;
|
||||
gchar *hoststr = NULL;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
@ -207,8 +208,22 @@ virt_viewer_session_vnc_open_uri(VirtViewerSession* session,
|
||||
|
||||
portstr = g_strdup_printf("%d", uri->port);
|
||||
|
||||
ret = vnc_display_open_host(self->priv->vnc, uri->server, portstr);
|
||||
if (uri->server) {
|
||||
if (uri->server[0] == '[') {
|
||||
gchar *tmp;
|
||||
hoststr = g_strdup(uri->server + 1);
|
||||
if ((tmp = strchr(hoststr, ']')))
|
||||
*tmp = '\0';
|
||||
} else {
|
||||
hoststr = g_strdup(uri->server);
|
||||
}
|
||||
}
|
||||
|
||||
ret = vnc_display_open_host(self->priv->vnc,
|
||||
hoststr,
|
||||
portstr);
|
||||
g_free(portstr);
|
||||
g_free(hoststr);
|
||||
xmlFreeURI(uri);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -91,10 +91,18 @@ virt_viewer_util_extract_host(const char *uristr,
|
||||
g_return_val_if_fail(uri != NULL, 1);
|
||||
|
||||
if (host) {
|
||||
if (!uri || !uri->server)
|
||||
if (!uri || !uri->server) {
|
||||
*host = g_strdup("localhost");
|
||||
else
|
||||
*host = g_strdup(uri->server);
|
||||
} else {
|
||||
if (uri->server[0] == '[') {
|
||||
gchar *tmp;
|
||||
*host = g_strdup(uri->server + 1);
|
||||
if ((tmp = strchr(*host, ']')))
|
||||
*tmp = '\0';
|
||||
} else {
|
||||
*host = g_strdup(uri->server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user