update Changelog and comments about commit 9500253

This commit is contained in:
Thomas Bernard 2022-02-19 20:03:30 +01:00
parent 9e042264fa
commit 5231397bd6
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
2 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.484 2022/01/23 00:14:39 nanard Exp $
$Id: Changelog.txt,v 1.485 2022/02/19 18:58:23 nanard Exp $
2022/02/19:
prefer non-reserved over reserved addresses in getifaddr()
VERSION 2.3.0 : released on 2022/01/23

View File

@ -1,8 +1,8 @@
/* $Id: getifaddr.c,v 1.26 2019/05/20 19:54:08 nanard Exp $ */
/* $Id: getifaddr.c,v 1.28 2022/02/19 18:58:25 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2019 Thomas Bernard
* (c) 2006-2022 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
@ -120,6 +120,10 @@ getifaddr(const char * ifname, char * buf, int len,
switch(ife->ifa_addr->sa_family)
{
case AF_INET:
/* only consider the address if it is the 1st candidate or
if it is not privante AND the current candidate is a private address.
So we return a private address only if there is no public address
on this interface */
if(!candidate ||
(addr_is_reserved(&((struct sockaddr_in *)candidate->ifa_addr)->sin_addr) &&
!addr_is_reserved(&((struct sockaddr_in *)ife->ifa_addr)->sin_addr)))