use of org.freenetproject.ForwardPortStatus in project i2p.i2p by i2p.
the class UPnP method deviceRemoved.
/**
* DeviceChangeListener
*/
public void deviceRemoved(Device dev) {
String udn = dev.getUDN();
if (_log.shouldLog(Log.WARN))
_log.warn("UP&P device removed : " + dev.getFriendlyName() + " UDN: " + udn);
ForwardPortCallback fpc = null;
Map<ForwardPort, ForwardPortStatus> removeMap = null;
synchronized (lock) {
if (udn != null)
_otherUDNs.remove(udn);
else
_otherUDNs.remove("???");
if (_router == null)
return;
// I2P this wasn't working
// if(_router.equals(dev)) {
String type = dev.getDeviceType();
if ((ROUTER_DEVICE.equals(type) || ROUTER_DEVICE_2.equals(type)) && dev.isRootDevice() && stringEquals(_router.getFriendlyName(), dev.getFriendlyName()) && stringEquals(_router.getUDN(), udn)) {
if (_log.shouldLog(Log.WARN))
_log.warn("UP&P IGD device removed : " + dev.getFriendlyName());
// TODO promote an IGD from _otherUDNs ??
// For now, just clear the others so they can be promoted later
// after a rescan.
_otherUDNs.clear();
_router = null;
_service = null;
_eventVars.clear();
_serviceLacksAPM = false;
if (!portsForwarded.isEmpty()) {
fpc = forwardCallback;
removeMap = new HashMap<ForwardPort, ForwardPortStatus>(portsForwarded.size());
for (ForwardPort port : portsForwarded) {
ForwardPortStatus fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "UPnP device removed", port.portNumber);
}
}
portsForwarded.clear();
}
}
if (fpc != null) {
fpc.portForwardStatus(removeMap);
}
}
use of org.freenetproject.ForwardPortStatus in project i2p.i2p by i2p.
the class UPnP method registerPorts.
/**
* postControlAction() can take many seconds, especially if it's failing,
* and onChangePublicPorts() may be called from threads we don't want to slow down,
* so throw this in a thread.
*/
private void registerPorts(Set<ForwardPort> portsToForwardNow) {
if (_serviceLacksAPM) {
if (_log.shouldLog(Log.WARN))
_log.warn("UPnP device does not support port forwarding");
Map<ForwardPort, ForwardPortStatus> map = new HashMap<ForwardPort, ForwardPortStatus>(portsToForwardNow.size());
for (ForwardPort port : portsToForwardNow) {
ForwardPortStatus fps = new ForwardPortStatus(ForwardPortStatus.DEFINITE_FAILURE, "UPnP device does not support port forwarding", port.portNumber);
map.put(port, fps);
}
forwardCallback.portForwardStatus(map);
return;
}
if (_log.shouldLog(Log.INFO))
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
Thread t = new I2PThread(new RegisterPortsThread(portsToForwardNow));
t.setName("UPnP Port Opener " + __id.incrementAndGet());
t.setDaemon(true);
t.start();
}
Aggregations