Commit 7adfea8c authored by Max Kellermann's avatar Max Kellermann

system/resolver: return path of UNIX domain sockets

getnameinfo() doesn't work well - it always returns "localhost".
parent eab1a776
ver 0.18.1 (2013/11/??)
* protocol:
- always ignore whitespace at the end of the line
* networking:
- log UNIX domain path names instead of "localhost"
* filter:
- autoconvert: fix "volume_normalization" with mp3 files
* add missing files to source tarball
......
......@@ -32,6 +32,10 @@
#include <winsock.h>
#endif
#ifdef HAVE_UN
#include <sys/un.h>
#endif
#include <string.h>
#include <stdio.h>
......@@ -40,6 +44,17 @@ const Domain resolver_domain("resolver");
char *
sockaddr_to_string(const struct sockaddr *sa, size_t length, Error &error)
{
#ifdef HAVE_UN
if (sa->sa_family == AF_UNIX) {
/* return path of UNIX domain sockets */
const sockaddr_un &s_un = *(const sockaddr_un *)sa;
if (length < sizeof(s_un) || s_un.sun_path[0] == 0)
return g_strdup("local");
return g_strdup(s_un.sun_path);
}
#endif
#if defined(HAVE_IPV6) && defined(IN6_IS_ADDR_V4MAPPED)
const struct sockaddr_in6 *a6 = (const struct sockaddr_in6 *)sa;
struct sockaddr_in a4;
......@@ -70,13 +85,6 @@ sockaddr_to_string(const struct sockaddr *sa, size_t length, Error &error)
return NULL;
}
#ifdef HAVE_UN
if (sa->sa_family == AF_UNIX)
/* "serv" contains corrupt information with unix
sockets */
return g_strdup(host);
#endif
#ifdef HAVE_IPV6
if (strchr(host, ':') != NULL)
return g_strconcat("[", host, "]:", serv, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment