--- a/src/server/daemon/httprequest.c Wed Oct 12 23:34:20 2022 +0200 +++ b/src/server/daemon/httprequest.c Thu Oct 13 18:46:00 2022 +0200 @@ -164,9 +164,8 @@ sn->config = request->connection->listener->cfg; // add ip to sn->client pblock - char ip_str[INET_ADDRSTRLEN]; - // TODO: ipv6 if(request->connection->addr_type == CONN_ADDR_IPV4) { + char ip_str[INET_ADDRSTRLEN]; if(inet_ntop( AF_INET, &request->connection->address.address_v4.sin_addr, @@ -175,6 +174,16 @@ { pblock_kvinsert(pb_key_ip, ip_str, INET_ADDRSTRLEN, sn->sn.client); } + } else if(request->connection->addr_type == CONN_ADDR_IPV6) { + char ip_str[INET6_ADDRSTRLEN]; + if(inet_ntop( + AF_INET6, + &request->connection->address.address_v6.sin6_addr, + ip_str, + INET6_ADDRSTRLEN) != NULL) + { + pblock_kvinsert(pb_key_ip, ip_str, INET6_ADDRSTRLEN, sn->sn.client); + } } // init NSAPI request structure @@ -342,7 +351,16 @@ char *hosthdr = pblock_findkeyval(pb_key_host, rq->rq.headers); if(hosthdr) { char *host = pool_strdup(pool, hosthdr); - char *portstr = strchr(host, ':'); + char *portstr = NULL; + if(host[0] != '[') { + portstr = strchr(host, ':'); + } else { + char *v6end = strchr(host, ']'); + if(v6end) { + portstr = strchr(v6end, ':'); + } + } + if(portstr) { *portstr = '\0'; }