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_DELAYand then tries all methods again. It never gives up.
-
-
Field Summary
Fields Modifier and Type Field Description static DurationMAPPING_LIFETIMEstatic StringPORT_MAPPERstatic DurationRETRY_DELAY
-
Constructor Summary
Constructors Constructor Description PortMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voideventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)Gets called if aEventwas emitted.protected voidmatchedRead(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:HandlerGets called if aEventwas emitted.- Specified by:
eventTriggeredin interfaceHandler- Overrides:
eventTriggeredin 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:SimpleInboundEventAwareHandlerIs called for each message of typeSimpleInboundEventAwareHandler.- Specified by:
matchedReadin classSimpleInboundEventAwareHandler<AddressedByteBuf,Event,Address>- Parameters:
ctx- handler contextsender- the sender of the messagemsg- the messagefuture- the future of the message
-
-