Manage ipv6 in get_ip_str function#116
Manage ipv6 in get_ip_str function#116etr merged 2 commits intoetr:masterfrom GMercat:fix_get_ip_str_for_ip6
Conversation
sockaddr_in (IPv4) is the same size as sockaddr, which is why getnameinfo() is working for IPv4. But sockaddr_in6 (IPv6) is larger than sockaddr, which is why getnameinfo() fails.
src/http_utils.cpp
Outdated
| { | ||
| result = to_ret; | ||
| } | ||
| else |
There was a problem hiding this comment.
The rest looks good but I am not sure why you are clearing the result here.
There was a problem hiding this comment.
I can remove the else statement, no prob.
Because it's how i code 😉 For this type of function, i prefer return a cleared object instead of do nothing about it. Users of this function have always a coherent object (setted or cleared). It's just my point of view.
Tell me what do you want, remove or not?
There was a problem hiding this comment.
And you are probably right. For now, remove it though for consistency with the rest of the codebase.
I am anyhow disagreeing with my old self here and I am going to rewrite the signature of those methods to avoid passing in input references (let the return values be return values) so the clear shouldn't be necessary anymore (sorry... I saw this part of my old code while reviewing your CR and I shivered).
There was a problem hiding this comment.
Ok.
It's never easy to re-read our old code 😄
|
Merging. Thanks for the work! |
sockaddr_in (IPv4) is the same size as sockaddr, which is why getnameinfo() is working for IPv4. But sockaddr_in6 (IPv6) is larger than sockaddr, which is why getnameinfo() fails.