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 foraddress
at routermapper
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this port mapping.Returns the external address of the port mapping.io.reactivex.rxjava3.core.Observable<Optional<InetSocketAddress>>
Returns anObservable
which 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 foraddress
at 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
null
if mapping has been closed
-
toString
-
externalAddress
Returns anObservable
which 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:
Observable
with current and future external addresses
-