Class PortMapper
- java.lang.Object
-
- org.drasyl.pipeline.skeleton.HandlerAdapter
-
- org.drasyl.pipeline.skeleton.AddressHandlerAdapter<A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler<I,Event,A>
-
- org.drasyl.pipeline.skeleton.SimpleInboundHandler<AddressedByteBuf,Address>
-
- org.drasyl.remote.handler.portmapper.PortMapper
-
- All Implemented Interfaces:
Handler
public class PortMapper extends SimpleInboundHandler<AddressedByteBuf,Address>
This handler tries to create a port forwarding for the UDP server using different methods (PCP, NAT-PMP, UPnP-IGD, etc.). For this purpose, the individual methods are tried one after one. If all methods fail, the program waits forRETRY_DELAY
and then tries all methods again. It never gives up.
-
-
Field Summary
Fields Modifier and Type Field Description static Duration
MAPPING_LIFETIME
static String
PORT_MAPPER
static Duration
RETRY_DELAY
-
Constructor Summary
Constructors Constructor Description PortMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.protected void
matchedRead(HandlerContext ctx, Address sender, AddressedByteBuf msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleInboundEventAwareHandler
.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundHandler
matchedEventTriggered
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler
acceptEvent, acceptInbound, read
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
exceptionCaught, handlerAdded, handlerRemoved, write
-
-
-
-
Field Detail
-
PORT_MAPPER
public static final String PORT_MAPPER
- See Also:
- Constant Field Values
-
MAPPING_LIFETIME
public static final Duration MAPPING_LIFETIME
-
RETRY_DELAY
public static final Duration RETRY_DELAY
-
-
Method Detail
-
eventTriggered
public void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aEvent
was emitted.- Specified by:
eventTriggered
in interfaceHandler
- Overrides:
eventTriggered
in classSimpleInboundHandler<AddressedByteBuf,Address>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
matchedRead
protected void matchedRead(HandlerContext ctx, Address sender, AddressedByteBuf msg, CompletableFuture<Void> future)
Description copied from class:SimpleInboundEventAwareHandler
Is called for each message of typeSimpleInboundEventAwareHandler
.- Specified by:
matchedRead
in classSimpleInboundEventAwareHandler<AddressedByteBuf,Event,Address>
- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- the future of the message
-
-