diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 8dc2706..18c896d 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,4 +1,8 @@ -$Id: Changelog.txt,v 1.398 2015/04/26 14:43:27 nanard Exp $ +$Id: Changelog.txt,v 1.400 2015/08/26 07:32:31 nanard Exp $ + +2015/08/25: + better bind socket to right interface(s), + using struct ip_mreqn, SO_BINDTODEVICE 2015/04/30: Adding linux/nftables support diff --git a/miniupnpd/minissdp.c b/miniupnpd/minissdp.c index f7ebfe5..038fae0 100644 --- a/miniupnpd/minissdp.c +++ b/miniupnpd/minissdp.c @@ -1,4 +1,4 @@ -/* $Id: minissdp.c,v 1.73 2015/01/17 11:26:05 nanard Exp $ */ +/* $Id: minissdp.c,v 1.77 2015/08/26 07:36:52 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2015 Thomas Bernard @@ -177,14 +177,17 @@ OpenAndConfSSDPReceiveSocket(int ipv6) "OpenAndConfSSDPReceiveSocket"); } -/* TODO: Bind to device only if one LAN interface -#ifndef MULTIPLE_EXTERNAL_IP - if(setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, int_if_name, strlen(int_if_name)) < 0) +#if defined(SO_BINDTODEVICE) && !defined(MULTIPLE_EXTERNAL_IP) + /* One and only one LAN interface */ + if(lan_addrs.lh_first != NULL && lan_addrs.lh_first->list.le_next == NULL + && strlen(lan_addrs.lh_first->ifname) > 0) { - syslog(LOG_WARNING, "setsockopt(udp, SO_BINDTODEVICE): %m"); + if(setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, + lan_addrs.lh_first->ifname, + strlen(lan_addrs.lh_first->ifname)) < 0) + syslog(LOG_WARNING, "setsockopt(udp, SO_BINDTODEVICE): %m"); } -#endif -*/ +#endif /* defined(SO_BINDTODEVICE) && !defined(MULTIPLE_EXTERNAL_IP) */ if(bind(s, (struct sockaddr *)&sockname, sockname_len) < 0) { diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 394bee2..546d16a 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpd.c,v 1.206 2015/01/17 11:26:04 nanard Exp $ */ +/* $Id: miniupnpd.c,v 1.210 2015/08/26 07:32:32 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2015 Thomas Bernard @@ -370,14 +370,17 @@ OpenAndConfHTTPSocket(unsigned short * port) listenname_len = sizeof(struct sockaddr_in); #endif -/* TODO: Bind to device only if one LAN interface -#ifndef MULTIPLE_EXTERNAL_IP - if(setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, int_if_name, strlen(int_if_name)) < 0) +#if defined(SO_BINDTODEVICE) && !defined(MULTIPLE_EXTERNAL_IP) + /* One and only one LAN interface */ + if(lan_addrs.lh_first != NULL && lan_addrs.lh_first->list.le_next == NULL + && strlen(lan_addrs.lh_first->ifname) > 0) { - syslog(LOG_WARNING, "setsockopt(udp, SO_BINDTODEVICE): %m"); + if(setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, + lan_addrs.lh_first->ifname, + strlen(lan_addrs.lh_first->ifname)) < 0) + syslog(LOG_WARNING, "setsockopt(udp, SO_BINDTODEVICE): %m"); } -#endif -*/ +#endif /* defined(SO_BINDTODEVICE) && !defined(MULTIPLE_EXTERNAL_IP) */ #ifdef ENABLE_IPV6 if(bind(s,