On 14/09/2021 04.58, miim wrote:
I've reviewed the last three years of the list and I can't find a commentary on
this issue, nor was I able to find one on goofle.
Consider an incoming request which might have either an IPv4 or an IPv6 address. The module
wants to know which one. It is possible to sscanf the value in r->useragent_ip to see
which format it matches. However, this is a relatively expensive operation for a small
amount of info unless "most" are one or the other; then the test sequence can be
optimized ... which according to Finagle's Law, will always be the wrong way around on
somebody else's system.
Is there a more efficient way to do this?
Hello,
I've not tested this, but try inspecting
r->connection->client_addr->family
(or r->useragent_addr->family, it probably points to the same structure)
If family is not initialized (though I think it is), then check
...->ipaddr_len or ...->salen. Have a look at
/usr/include/apr-1.0/apr_network_io.h for all the fields of a
apr_sockaddr_t structure.
Regards,
Sorin