Package org.drasyl.util
Class PortMappingUtil.PortMapping
- java.lang.Object
-
- org.drasyl.util.PortMappingUtil.PortMapping
-
- Enclosing class:
- PortMappingUtil
public static class PortMappingUtil.PortMapping extends Object
Represents a port mapping.
-
-
Constructor Summary
Constructors Constructor Description PortMapping(com.offbynull.portmapper.mapper.PortMapper mapper, InetSocketAddress address)
Attempts to create a port mapping foraddress
at routermapper
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this port mapping.InetSocketAddress
currentExternalAddress()
Returns the external address of the port mapping.io.reactivex.rxjava3.core.Observable<Optional<InetSocketAddress>>
externalAddress()
Returns anObservable
which emits the current and every future external addresses.String
toString()
-
-
-
Constructor Detail
-
PortMapping
public PortMapping(com.offbynull.portmapper.mapper.PortMapper mapper, InetSocketAddress address)
Attempts to create a port mapping foraddress
at routermapper
.- Parameters:
mapper
- router where the port mapping will be requested.address
- address to be exposed- Throws:
IllegalStateException
- if the port could not be mapped for any reason
-
-
Method Detail
-
close
public void close()
Closes this port mapping.
-
currentExternalAddress
public InetSocketAddress currentExternalAddress()
Returns the external address of the port mapping.- Returns:
- external address or
null
if mapping has been closed
-
externalAddress
public io.reactivex.rxjava3.core.Observable<Optional<InetSocketAddress>> 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
-
-