Changeset f869b8a
- Timestamp:
- Feb 27, 2018 3:09:49 PM (3 years ago)
- Branches:
- master
- Children:
- ab182d08
- Parents:
- 7035db2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
router/java/src/net/i2p/router/transport/UPnP.java
r7035db2 rf869b8a 85 85 private Service _service; 86 86 // UDN -> friendly name 87 private final Map<String, String> _otherUDNs; 87 private final Map<String, String> _otherUDNs; 88 private final Map<String, String> _eventVars; 88 89 private boolean isDisabled = false; // We disable the plugin if more than one IGD is found 89 90 private volatile boolean _serviceLacksAPM; … … 108 109 portsToForward = new HashSet<ForwardPort>(); 109 110 portsForwarded = new HashSet<ForwardPort>(); 110 _otherUDNs = new HashMap<String, String>(4); 111 _otherUDNs = new HashMap<String, String>(4); 112 _eventVars = new HashMap<String, String>(4); 113 } 114 115 public synchronized boolean runPlugin() { 111 116 addDeviceChangeListener(this); 112 } 113 114 public synchronized boolean runPlugin() { 117 addEventListener(this); 115 118 synchronized(lock) { 116 119 portsToForward.clear(); 117 120 portsForwarded.clear(); 121 _eventVars.clear(); 118 122 } 119 123 return super.start(); … … 124 128 */ 125 129 public synchronized void terminate() { 130 removeDeviceChangeListener(this); 131 removeEventListener(this); 126 132 synchronized(lock) { 127 133 portsToForward.clear(); 134 _eventVars.clear(); 128 135 } 129 136 // this gets spun off in a thread... … … 367 374 _router = null; 368 375 _service = null; 376 _eventVars.clear(); 369 377 _serviceLacksAPM = false; 370 378 if (!portsForwarded.isEmpty()) { … … 387 395 /** 388 396 * EventListener callback - 389 * unused for now - how many devices support events?397 * unused for now - supported in miniupnpd as of 1.1 390 398 */ 391 399 public void eventNotifyReceived(String uuid, long seq, String varName, String value) { 392 if (_log.shouldLog(Log.WARN)) 393 _log.warn("Event: " + uuid + ' ' + seq + ' ' + varName + '=' + value); 400 if (uuid == null || varName == null || value == null) 401 return; 402 if (varName.length() > 128 || value.length() > 128) 403 return; 404 String old = null; 405 synchronized(lock) { 406 if (_service == null || !uuid.equals(_service.getSID())) 407 return; 408 if (_eventVars.size() >= 20 && !_eventVars.containsKey(varName)) 409 return; 410 old = _eventVars.put(varName, value); 411 } 412 // The following four variables are "evented": 413 // PossibleConnectionTypes: {Unconfigured IP_Routed IP_Bridged} 414 // ConnectionStatus: {Unconfigured Connecting Connected PendingDisconnect Disconnecting Disconnected} 415 // ExternalIPAddress: string 416 // PortMappingNumberOfEntries: int 417 if (!value.equals(old)) { 418 if (_log.shouldDebug()) 419 _log.debug("Event: " + varName + " changed from " + old + " to " + value); 420 } 421 // call callback... 394 422 } 395 423
Note: See TracChangeset
for help on using the changeset viewer.