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<io.netty.buffer.ByteBuf,InetSocketAddressWrapper>
-
- org.drasyl.remote.handler.portmapper.PortMapper
-
- All Implemented Interfaces:
Handler
public class PortMapper extends SimpleInboundHandler<io.netty.buffer.ByteBuf,InetSocketAddressWrapper>
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 Duration
RETRY_DELAY
-
Constructor Summary
Constructors Constructor Description PortMapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
matchedInbound(HandlerContext ctx, InetSocketAddressWrapper sender, io.netty.buffer.ByteBuf msg, CompletableFuture<Void> future)
Is called for each message of typeSimpleInboundEventAwareHandler
.void
onEvent(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundHandler
matchedEvent
-
Methods inherited from class org.drasyl.pipeline.skeleton.SimpleInboundEventAwareHandler
acceptEvent, acceptInbound, onInbound
-
Methods inherited from class org.drasyl.pipeline.skeleton.AddressHandlerAdapter
acceptAddress
-
Methods inherited from class org.drasyl.pipeline.skeleton.HandlerAdapter
onAdded, onException, onOutbound, onRemoved
-
-
-
-
Method Detail
-
onEvent
public void onEvent(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Description copied from interface:Handler
Gets called if aEvent
was emitted.- Specified by:
onEvent
in interfaceHandler
- Overrides:
onEvent
in classSimpleInboundHandler<io.netty.buffer.ByteBuf,InetSocketAddressWrapper>
- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
matchedInbound
protected void matchedInbound(HandlerContext ctx, InetSocketAddressWrapper sender, io.netty.buffer.ByteBuf msg, CompletableFuture<Void> future)
Description copied from class:SimpleInboundEventAwareHandler
Is called for each message of typeSimpleInboundEventAwareHandler
.- Specified by:
matchedInbound
in classSimpleInboundEventAwareHandler<io.netty.buffer.ByteBuf,Event,InetSocketAddressWrapper>
- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- the future of the message
-
-