From curl_easy_getinfo
CURLINFO_PRIMARY_IP
Pass a pointer to a char pointer to receive the pointer to a zero-terminated string holding the IP address of the most recent connection done with this curl handle. This string may be IPv6 if that's enabled. Note that you get a pointer to a memory area that will be re-used at next request so you need to copy the string if you want to keep the information. (Added in 7.19.0)
This should be the final connection after any redirection.
Another way might be to use CURLINFO_LASTSOCKET
and extract the peer from that, but I don't know how long the used socket will be valid after the connection is complete.