benluteijn / cherokee

Automatically exported from code.google.com/p/cherokee
0 stars 1 forks source link

IPv6 sources #269

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Looking at the source:

http://svn.cherokee-project.com/browser/cherokee/trunk/cherokee/source.c#L112

It seems sources are limited to IPv4

Original issue reported on code.google.com by ste...@konink.de on 13 Dec 2008 at 7:27

GoogleCodeExporter commented 9 years ago
r2608 implemented it.
Stefan, could you please confirm that it works for you?

Original comment by alobbs on 17 Dec 2008 at 4:58

GoogleCodeExporter commented 9 years ago
Not yet able to test (PHP is not supporting v6); but I would like to comment on 
the
admin part; it accepts everything even IP syntax that is invalid.

Original comment by ste...@konink.de on 22 Dec 2008 at 2:59

GoogleCodeExporter commented 9 years ago
Bug triaging:
This bug has been fixed two weeks now. I'm closing it.

Original comment by alobbs on 3 Jan 2009 at 9:38

GoogleCodeExporter commented 9 years ago
It might be overly complex, but I think this should be done for reliable 
parsing.
Still will not fix the IPv6 proxy issues, working on that.

Index: source.c
===================================================================
--- source.c    (revision 2793)
+++ source.c    (working copy)
@@ -209,22 +209,46 @@
                cherokee_buffer_add_buffer (&src->unix_socket, host);
                return ret_ok;
        } 
-
-       /* Host name
+#ifdef HAVE_IPV6
+       /* IPv6 host
         */
-       p = strchr (host->buf, ':');
-       if (p == NULL) {
-               cherokee_buffer_add_buffer (&src->host, host);
-               return ret_ok;
-       } 
+       if (host->buf[0] == '[') {
+               p = strchr (host->buf, ']');
+               if (unlikely(p == NULL))
+                       return ret_error;
+
+               *p = '\0';
+
+               cherokee_buffer_add (&src->host, (host->buf + 1), (p - 
(host->buf + 1)));
+
+               *p = ']';
+
+               p++;
+
+               if (*p != ':') {
+                       return ret_ok;
+               }
+
+               src->port = atoi (p+1);
+       } else
+#endif
+       {
+               /* Host name
+                */
+               p = strchr (host->buf, ':');
+               if (p == NULL) {
+                       cherokee_buffer_add_buffer (&src->host, host);
+                       return ret_ok;
+               }
+
+               /* Host name + port
+                */
+               *p = '\0';
+               src->port = atoi (p+1);
+               cherokee_buffer_add (&src->host, host->buf, p - host->buf);
+               *p = ':';
+       }

-       /* Host name + port
-        */
-       *p = '\0';
-       src->port = atoi (p+1);
-       cherokee_buffer_add (&src->host, host->buf, p - host->buf);
-       *p = ':';
-
        return ret_ok;
 }

Original comment by ste...@konink.de on 31 Jan 2009 at 8:28

GoogleCodeExporter commented 9 years ago
Smaller patch.

Index: source.c
===================================================================
--- source.c    (revision 2793)
+++ source.c    (working copy)
@@ -209,22 +209,39 @@
                cherokee_buffer_add_buffer (&src->unix_socket, host);
                return ret_ok;
        } 
-
-       /* Host name
+#ifdef HAVE_IPV6
+       /* IPv6 host
         */
-       p = strchr (host->buf, ':');
-       if (p == NULL) {
-               cherokee_buffer_add_buffer (&src->host, host);
-               return ret_ok;
-       } 
+       if (host->buf[0] == '[') {
+               p = strchr (host->buf, ']');
+               if (unlikely(p == NULL))
+                       return ret_error;
+
+               cherokee_buffer_add (&src->host, (host->buf + 1), (p - 
(host->buf + 1)));
+
+               if (p[1] != ':') 
+                       return ret_ok;
+
+               src->port = atoi (p+2);
+       } else
+#endif
+       {
+               /* Host name
+                */
+               p = strchr (host->buf, ':');
+               if (p == NULL) {
+                       cherokee_buffer_add_buffer (&src->host, host);
+                       return ret_ok;
+               }
+
+               /* Host name + port
+                */
+               *p = '\0';
+               src->port = atoi (p+1);
+               cherokee_buffer_add (&src->host, host->buf, p - host->buf);
+               *p = ':';
+       }

-       /* Host name + port
-        */
-       *p = '\0';
-       src->port = atoi (p+1);
-       cherokee_buffer_add (&src->host, host->buf, p - host->buf);
-       *p = ':';
-
        return ret_ok;
 }

Original comment by ste...@konink.de on 31 Jan 2009 at 8:37

GoogleCodeExporter commented 9 years ago

Original comment by ste...@konink.de on 1 Feb 2009 at 2:24

GoogleCodeExporter commented 9 years ago
Committed; r2815:

   http://svn.cherokee-project.com/changeset/2815

Thanks Stefan. Good job! :-)

Original comment by alobbs on 1 Feb 2009 at 2:13