/** * Call when the ports might have changed * The transports can call this pretty quickly at startup, * which can have multiple UPnP threads running at once, but * that should be ok. */ public void update(Set<TransportManager.Port> ports) { if (_log.shouldLog(Log.DEBUG)) _log.debug("UPnP Update with " + ports.size() + " ports"); //synchronized(this) { // TODO // called too often and may block for too long // may not have started if net was disconnected previously //if (!_isRunning && !ports.isEmpty()) // start(); if (!_isRunning) return; //} Set<ForwardPort> forwards = new HashSet<ForwardPort>(ports.size()); for (TransportManager.Port entry : ports) { String style = entry.style; int port = entry.port; int protocol = -1; if ("SSU".equals(style)) protocol = ForwardPort.PROTOCOL_UDP_IPV4; else if ("NTCP".equals(style)) protocol = ForwardPort.PROTOCOL_TCP_IPV4; else continue; if (_log.shouldLog(Log.DEBUG)) _log.debug("Adding: " + style + " " + port); ForwardPort fp = new ForwardPort(style, false, protocol, port); forwards.add(fp); } // non-blocking _upnp.onChangePublicPorts(forwards, _upnpCallback); }