From 90096c0a454e11768a263c3ce2b4107d7bebdefd Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 2 Dec 2014 17:27:05 -0800 Subject: [PATCH] When using a systemd socket, retrieve its local address. --- src/proxy/app.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/proxy/app.c b/src/proxy/app.c index 2b6fc81f..69da1c72 100644 --- a/src/proxy/app.c +++ b/src/proxy/app.c @@ -19,6 +19,7 @@ #include #ifdef HAVE_LIBSYSTEMD +# include # include #endif @@ -231,12 +232,8 @@ dnscrypt_proxy_start_listeners(ProxyContext * const proxy_context) evutil_format_sockaddr_port((const struct sockaddr *) &proxy_context->resolver_sockaddr, resolver_addr_s, sizeof resolver_addr_s); -#ifdef HAVE_LIBSYSTEMD - logger(proxy_context, LOG_NOTICE, "Proxying to %s", resolver_addr_s); -#else logger(proxy_context, LOG_NOTICE, "Proxying from %s to %s", local_addr_s, resolver_addr_s); -#endif proxy_context->listeners_started = 1; #ifdef HAVE_LIBSYSTEMD sd_notify(0, "READY=1"); @@ -294,6 +291,13 @@ init_descriptors_from_systemd(ProxyContext * const proxy_context) "No systemd TCP socket passed in"); return -1; } + if (getsockname(proxy_context->udp_listener_handle, + (struct sockaddr *) &proxy_context->local_sockaddr, + &proxy_context->local_sockaddr_len) != 0) { + logger_noformat(proxy_context, LOG_ERR, + "Unable to get the local systemd UDP socket address"); + return -1; + } return 0; } #endif