Package org.drasyl.util
Class PortMappingUtil.PortMapping
java.lang.Object
org.drasyl.util.PortMappingUtil.PortMapping
- Enclosing class:
- PortMappingUtil
Represents a port mapping.
-
Constructor Summary
ConstructorsConstructorDescriptionPortMapping(com.offbynull.portmapper.mapper.PortMapper mapper, InetSocketAddress address, PortMappingUtil.Protocol protocol) Attempts to create a port mapping foraddressat routermapper. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this port mapping.Returns the external address of the port mapping.io.reactivex.rxjava3.core.Observable<Optional<InetSocketAddress>>Returns anObservablewhich emits the current and every future external addresses.toString()
-
Constructor Details
-
PortMapping
public PortMapping(com.offbynull.portmapper.mapper.PortMapper mapper, InetSocketAddress address, PortMappingUtil.Protocol protocol) Attempts to create a port mapping foraddressat routermapper.- Parameters:
mapper- router where the port mapping will be requested.address- address to be exposedprotocol- protocol to be exposed- Throws:
IllegalStateException- if the port could not be mapped for any reason
-
-
Method Details
-
close
public void close()Closes this port mapping. -
currentExternalAddress
Returns the external address of the port mapping.- Returns:
- external address or
nullif mapping has been closed
-
toString
-
externalAddress
Returns anObservablewhich emits the current and every future external addresses. Can be used to observe this port mapping for address changes made by the exposing router.- Returns:
Observablewith current and future external addresses
-