mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
try to cover AF_LOCAL in libwebsockets_get_peer_addresses
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
f92def7eef
commit
7627af52a3
1 changed files with 11 additions and 3 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
#else
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#ifdef LWS_OPENSSL_SUPPORT
|
||||
|
@ -371,6 +372,7 @@ libwebsockets_get_peer_addresses(int fd, char *name, int name_len,
|
|||
char ip[128];
|
||||
unsigned char *p;
|
||||
int n;
|
||||
struct sockaddr_un *un;
|
||||
|
||||
rip[0] = '\0';
|
||||
name[0] = '\0';
|
||||
|
@ -400,11 +402,17 @@ libwebsockets_get_peer_addresses(int fd, char *name, int name_len,
|
|||
p = (unsigned char *)host1->h_addr_list[n++];
|
||||
if (p == NULL)
|
||||
continue;
|
||||
if (host1->h_addrtype != AF_INET)
|
||||
if ((host1->h_addrtype != AF_INET) &&
|
||||
(host1->h_addrtype != AF_LOCAL))
|
||||
continue;
|
||||
|
||||
sprintf(ip, "%u.%u.%u.%u",
|
||||
p[0], p[1], p[2], p[3]);
|
||||
if (host1->h_addrtype == AF_INET)
|
||||
sprintf(ip, "%u.%u.%u.%u", p[0], p[1], p[2], p[3]);
|
||||
else {
|
||||
un = (struct sockaddr_un *)p;
|
||||
strncpy(ip, un->sun_path, sizeof(ip) -1);
|
||||
ip[sizeof(ip) - 1] = '\0';
|
||||
}
|
||||
p = NULL;
|
||||
strncpy(rip, ip, rip_len);
|
||||
rip[rip_len - 1] = '\0';
|
||||
|
|
Loading…
Add table
Reference in a new issue