Klaus Demo nginx / cd8c055
Merge of r4671: support for IPv6 literals in proxy_pass and so on. Maxim Dounin 10 years ago
1 changed file(s) with 31 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
807807
808808 u->uri.len = last - uri;
809809 u->uri.data = uri;
810
811 last = uri;
810812 }
811813
812814 if (*port == ':') {
839841 return NGX_ERROR;
840842 }
841843
842 u->host.len = len;
843 u->host.data = host;
844 u->host.len = len + 2;
845 u->host.data = host - 1;
844846
845847 if (ngx_inet6_addr(host, len, sin6->sin6_addr.s6_addr) != NGX_OK) {
846848 u->err = "invalid IPv6 address";
849851
850852 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
851853 u->wildcard = 1;
852 }
853
854 u->family = AF_INET6;
855
856 if (u->no_resolve) {
857 return NGX_OK;
858854 }
859855
860856 if (u->no_port) {
861857 u->port = u->default_port;
862858 sin6->sin6_port = htons(u->default_port);
863859 }
860
861 u->family = AF_INET6;
862 u->naddrs = 1;
863
864 u->addrs = ngx_pcalloc(pool, sizeof(ngx_addr_t));
865 if (u->addrs == NULL) {
866 return NGX_ERROR;
867 }
868
869 sin6 = ngx_pcalloc(pool, sizeof(struct sockaddr_in6));
870 if (sin6 == NULL) {
871 return NGX_ERROR;
872 }
873
874 ngx_memcpy(sin6, u->sockaddr, sizeof(struct sockaddr_in6));
875
876 u->addrs[0].sockaddr = (struct sockaddr *) sin6;
877 u->addrs[0].socklen = sizeof(struct sockaddr_in6);
878
879 p = ngx_pnalloc(pool, u->host.len + sizeof(":65535") - 1);
880 if (p == NULL) {
881 return NGX_ERROR;
882 }
883
884 u->addrs[0].name.len = ngx_sprintf(p, "%V:%d",
885 &u->host, u->port) - p;
886 u->addrs[0].name.data = p;
864887
865888 return NGX_OK;
866889