net.i2p.router.transport

## Class UPnPManager

- java.lang.Object
- - net.i2p.router.transport.UPnPManager

-     class UPnPManager
      extends Object

  Universal Plug and Play (UPnP) manager for NAT traversal and port forwarding. This class manages UPnP operations to automatically configure port forwarding on UPnP-enabled routers, allowing I2P to work through NAT and firewalls. It bridges between I2P's RouterAddress structures and the external FreeNet UPnP library. Core Features:
  - Automatic UPnP device discovery
  - Port forwarding request and management
  - External IP address detection
  - Gateway device mapping and configuration
  - Lease renewal and monitoring
  - Service advertisement for I2P
  UPnP Protocol Support:
  - SSDP (Simple Service Discovery Protocol)
  - HTTP interface for device configuration
  - SOAP-based control messages
  - Event-driven architecture with callbacks
  Integration:
  - Bridges I2P RouterAddress to FreeNet structures
  - Works with TransportManager for address updates
  - Provides callbacks for transport events
  - Handles multiple router discovery protocols
  Configuration:
  - Configurable HTTP and SSDP ports
  - Automatic device selection and fallback
  - Error handling and retry logic
  - Logging and monitoring capabilities

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UPnPManager(RouterContext context, TransportManager manager)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `renderStatusHTML()` Warning - blocking, very slow, queries the active router, will take many seconds if it has vanished.
    `boolean` | `rescan()` Call when IP or network connectivity might have changed.
    `void` | `start()` Blocking, may take a while.
    `void` | `stop()` Blocking, may take a while, up to 20 seconds
    `void` | `update(Set<TransportManager.Port> ports)` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UPnPManager

          public UPnPManager(RouterContext context,
                             TransportManager manager)

  - ### Method Detail

    - #### renderStatusHTML

          public String renderStatusHTML()

      Warning - blocking, very slow, queries the active router, will take many seconds if it has vanished.

    - #### rescan

          public boolean rescan()

      Call when IP or network connectivity might have changed. Starts UPnP if previous start failed, else starts a search. Must have called start() first, and not called stop(). Should be fast. This only starts the search, the responses will come in over the MX time (3 seconds).
      Returns:
        true if a rescan was actually fired off

    - #### start

          public void start()

      Blocking, may take a while. May be called even if already running.

    - #### stop

          public void stop()

      Blocking, may take a while, up to 20 seconds

    - #### update

          public void update(Set<TransportManager.Port> ports)

      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.