Transport: Don't open UPnP ports when force-firewalled

This commit is contained in:
zzz
2021-03-29 14:15:42 -04:00
parent e6f5ab967e
commit fed3063f36
2 changed files with 19 additions and 2 deletions

View File

@@ -201,6 +201,20 @@ public interface Transport {
*/
public TransportUtil.IPv6Config getIPv6Config();
/**
* This returns true if the force-firewalled setting is configured, false otherwise.
*
* @since 0.9.50 added to interface
*/
public boolean isIPv4Firewalled();
/**
* This returns true if the force-firewalled setting is configured, false otherwise.
*
* @since 0.9.50 added to interface
*/
public boolean isIPv6Firewalled();
public boolean isBacklogged(Hash peer);
/**

View File

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