From 30c27967ae2b25bcadf574ab35789be6c6b79481 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 5 Nov 2020 21:59:25 +0100 Subject: [PATCH] fix error message for IPV6. 2020 --- miniupnpd/upnphttp.c | 30 +++++++++++++++++++++++++++--- miniupnpd/upnphttp.h | 6 +++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/miniupnpd/upnphttp.c b/miniupnpd/upnphttp.c index fc8ccb6..e40bb7b 100644 --- a/miniupnpd/upnphttp.c +++ b/miniupnpd/upnphttp.c @@ -3,7 +3,7 @@ * Project : miniupnp * Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author : Thomas Bernard - * Copyright (c) 2005-2019 Thomas Bernard + * Copyright (c) 2005-2020 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file included in this distribution. * */ @@ -949,7 +949,19 @@ Process_upnphttp(struct upnphttp * h) } else if(n==0) { - syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", inet_ntoa(h->clientaddr)); +#ifdef ENABLE_IPV6 + if (h->ipv6) + { + char clientaddr_str[INET6_ADDRSTRLEN]; + if(inet_ntop(AF_INET6, &(h->clientaddr_v6), clientaddr_str, INET6_ADDRSTRLEN) == NULL) + strncpy(clientaddr_str, "*inet_ntop error*", sizeof(clientaddr_str)); + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", clientaddr_str); + } + else +#endif + { + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", inet_ntoa(h->clientaddr)); + } h->state = EToDelete; } else @@ -1019,7 +1031,19 @@ Process_upnphttp(struct upnphttp * h) } else if(n==0) { - syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", inet_ntoa(h->clientaddr)); +#ifdef ENABLE_IPV6 + if (h->ipv6) + { + char clientaddr_str[INET6_ADDRSTRLEN]; + if(inet_ntop(AF_INET6, &(h->clientaddr_v6), clientaddr_str, INET6_ADDRSTRLEN) == NULL) + strncpy(clientaddr_str, "*inet_ntop error*", sizeof(clientaddr_str)); + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", clientaddr_str); + } + else +#endif + { + syslog(LOG_WARNING, "HTTP Connection from %s closed unexpectedly", inet_ntoa(h->clientaddr)); + } h->state = EToDelete; } else diff --git a/miniupnpd/upnphttp.h b/miniupnpd/upnphttp.h index bf48b47..9d9cf48 100644 --- a/miniupnpd/upnphttp.h +++ b/miniupnpd/upnphttp.h @@ -1,8 +1,8 @@ /* $Id: upnphttp.h,v 1.42 2015/12/16 10:21:49 nanard Exp $ */ -/* vim: tabstop=4 shiftwidth=4 noexpandtab */ -/* MiniUPnP project +/* vim: tabstop=4 shiftwidth=4 noexpandtab + * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2015 Thomas Bernard + * (c) 2006-2020 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */