Transports: Don't open UPnP ports for disabled IPv4/v6

This commit is contained in:
zzz
2021-03-25 08:46:00 -04:00
parent aecd8efcca
commit 684506b0be
2 changed files with 10 additions and 2 deletions

View File

@@ -196,6 +196,11 @@ public interface Transport {
@Deprecated
public void recheckReachability();
/**
* @since 0.9.50 added to interface
*/
public TransportUtil.IPv6Config getIPv6Config();
public boolean isBacklogged(Hash peer);
/**

View File

@@ -797,10 +797,13 @@ public class TransportManager implements TransportEventListener {
port = udp.getRequestedPort();
}
if (port > 0) {
TransportUtil.IPv6Config config = t.getIPv6Config();
// ipv4
rv.add(new Port(t.getStyle(), port));
if (config != TransportUtil.IPv6Config.IPV6_ONLY)
rv.add(new Port(t.getStyle(), port));
// ipv6
if (_context.getProperty(PROP_ENABLE_UPNP_IPV6, DEFAULT_ENABLE_UPNP_IPV6)) {
if (_context.getProperty(PROP_ENABLE_UPNP_IPV6, DEFAULT_ENABLE_UPNP_IPV6) &&
config != TransportUtil.IPv6Config.IPV6_DISABLED) {
RouterAddress ra = t.getCurrentAddress(true);
if (ra == null) {
if (t.getStyle().equals(UDPTransport.STYLE)) {