diff options
Diffstat (limited to 'src/reqs.c')
-rw-r--r-- | src/reqs.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1530,7 +1530,7 @@ void handle_connection (struct conn_s *connptr, union sockaddr_union* addr) orderedmap hashofheaders = NULL; char sock_ipaddr[IP_LENGTH]; - char sock_ipaddr_mapped[IP_LENGTH]; + char sock_ipaddr_alt[IP_LENGTH]=""; char peer_ipaddr[IP_LENGTH]; getpeer_information (addr, peer_ipaddr, sizeof(peer_ipaddr)); @@ -1538,8 +1538,16 @@ void handle_connection (struct conn_s *connptr, union sockaddr_union* addr) if (config->bindsame) getsock_ip (fd, sock_ipaddr); - if (config->bind_ipv4mapped) - getmapped_ip (config->bind_ipv4mapped, sock_ipaddr, sock_ipaddr_mapped); + switch (SOCKADDR_UNION_AF(addr)) { + case AF_INET: + if (config->bind_ipv4mapped) + getmapped_ipv6 (config->bind_ipv4mapped, sock_ipaddr, sock_ipaddr_alt); + break; + case AF_INET6: + if (config->bind_ipv6mapped) + getmapped_ipv4 (config->bind_ipv6mapped, sock_ipaddr, sock_ipaddr_alt); + break; + } log_message (LOG_CONN, config->bindsame ? "Connect (file descriptor %d): %s at [%s]" : @@ -1548,7 +1556,7 @@ void handle_connection (struct conn_s *connptr, union sockaddr_union* addr) if(!conn_init_contents (connptr, peer_ipaddr, config->bindsame ? sock_ipaddr : NULL, - config->bind_ipv4mapped ? sock_ipaddr_mapped : NULL)) { + sock_ipconfig_alt[0] ? sock_ipaddr_alt : NULL)) { close (fd); return; } @@ -1689,7 +1697,7 @@ e401: } else { connptr->server_fd = opensock (request->host, request->port, connptr->server_ip_addr, - connptr->server_ip_addr_mapped); + connptr->server_ip_addr_alt); if (connptr->server_fd < 0) { indicate_http_error (connptr, 500, "Unable to connect", "detail", |