summaryrefslogtreecommitdiffhomepage
path: root/src/reqs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reqs.c')
-rw-r--r--src/reqs.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/reqs.c b/src/reqs.c
index e309fb2..d649db1 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1517,7 +1517,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));
@@ -1525,8 +1525,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]" :
@@ -1535,7 +1543,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;
}
@@ -1676,7 +1684,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",