[nginx] svn commit: r4671 - trunk/src/core
mdounin at mdounin.ru
mdounin at mdounin.ru
Mon Jun 4 14:07:34 UTC 2012
Author: mdounin
Date: 2012-06-04 14:07:34 +0000 (Mon, 04 Jun 2012)
New Revision: 4671
URL: http://trac.nginx.org/nginx/changeset/4671/nginx
Log:
Support for IPv6 literals in proxy_pass and so on.
Modified:
trunk/src/core/ngx_inet.c
Modified: trunk/src/core/ngx_inet.c
===================================================================
--- trunk/src/core/ngx_inet.c 2012-06-04 12:00:38 UTC (rev 4670)
+++ trunk/src/core/ngx_inet.c 2012-06-04 14:07:34 UTC (rev 4671)
@@ -808,6 +808,8 @@
u->uri.len = last - uri;
u->uri.data = uri;
+
+ last = uri;
}
if (*port == ':') {
@@ -840,8 +842,8 @@
return NGX_ERROR;
}
- u->host.len = len;
- u->host.data = host;
+ u->host.len = len + 2;
+ u->host.data = host - 1;
if (ngx_inet6_addr(host, len, sin6->sin6_addr.s6_addr) != NGX_OK) {
u->err = "invalid IPv6 address";
@@ -852,17 +854,38 @@
u->wildcard = 1;
}
+ if (u->no_port) {
+ u->port = u->default_port;
+ sin6->sin6_port = htons(u->default_port);
+ }
+
u->family = AF_INET6;
+ u->naddrs = 1;
- if (u->no_resolve) {
- return NGX_OK;
+ u->addrs = ngx_pcalloc(pool, sizeof(ngx_addr_t));
+ if (u->addrs == NULL) {
+ return NGX_ERROR;
}
- if (u->no_port) {
- u->port = u->default_port;
- sin6->sin6_port = htons(u->default_port);
+ sin6 = ngx_pcalloc(pool, sizeof(struct sockaddr_in6));
+ if (sin6 == NULL) {
+ return NGX_ERROR;
}
+ ngx_memcpy(sin6, u->sockaddr, sizeof(struct sockaddr_in6));
+
+ u->addrs[0].sockaddr = (struct sockaddr *) sin6;
+ u->addrs[0].socklen = sizeof(struct sockaddr_in6);
+
+ p = ngx_pnalloc(pool, u->host.len + sizeof(":65535") - 1);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ u->addrs[0].name.len = ngx_sprintf(p, "%V:%d",
+ &u->host, u->port) - p;
+ u->addrs[0].name.data = p;
+
return NGX_OK;
#else
More information about the nginx-devel
mailing list