|
|
@ -570,14 +570,15 @@ out: |
|
|
|
* INET6_ADDRSTRLEN size, port at least a string of 6 bytes */ |
|
|
|
* INET6_ADDRSTRLEN size, port at least a string of 6 bytes */ |
|
|
|
bool url_from_socket(const int sockd, char *url, char *port) |
|
|
|
bool url_from_socket(const int sockd, char *url, char *port) |
|
|
|
{ |
|
|
|
{ |
|
|
|
socklen_t addrlen = sizeof(struct sockaddr); |
|
|
|
struct sockaddr_storage storage; |
|
|
|
struct sockaddr addr; |
|
|
|
socklen_t addrlen = sizeof(struct sockaddr_storage); |
|
|
|
|
|
|
|
struct sockaddr *addr = (struct sockaddr *)&storage; |
|
|
|
|
|
|
|
|
|
|
|
if (sockd < 1) |
|
|
|
if (sockd < 1) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (getsockname(sockd, &addr, &addrlen)) |
|
|
|
if (getsockname(sockd, addr, &addrlen)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!url_from_sockaddr(&addr, url, port)) |
|
|
|
if (!url_from_sockaddr(addr, url, port)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|