[PATCH] proxy: support ipv6 addresses in brackets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Wolfgang Bumiller <w.bumiller@xxxxxxxxxxx>
---
 src/spice-uri.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/spice-uri.c b/src/spice-uri.c
index 82aefdb..2415857 100644
--- a/src/spice-uri.c
+++ b/src/spice-uri.c
@@ -114,11 +114,24 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
         uri = next;
     }
 
-    /* max 2 parts, host:port */
-    gchar **uriv = g_strsplit(uri, ":", 2);
+    /* ipv6 support */
+    gchar **uriv = NULL;
     const gchar *uri_port = NULL;
+    if (uri[0] == '[') {
+        gchar *end = strstr(uri+1, "]");
+        if (end) {
+            *end = 0;
+            uriv = g_malloc(sizeof(gchar*)*3);
+            uriv[0] = g_strdup(uri+1);
+            uriv[1] = (end[1] == ':') ? g_strdup(end+2) : NULL;
+            uriv[2] = NULL;
+        }
+    } else {
+        /* max 2 parts, host:port */
+        uriv = g_strsplit(uri, ":", 2);
+    }
 
-    if (uriv[0] == NULL || strlen(uriv[0]) == 0) {
+    if (!uriv || uriv[0] == NULL || strlen(uriv[0]) == 0) {
         g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
                     "Invalid hostname in uri address");
         goto end;
-- 
2.1.4


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]