Class NatPmpPortMapping
- java.lang.Object
-
- org.drasyl.remote.handler.portmapper.NatPmpPortMapping
-
- All Implemented Interfaces:
PortMapping
public class NatPmpPortMapping extends Object implements PortMapping
Port Forwarding on NAT-enabled routers via NAT-PMP.This methods requires the following steps:
- identify own default network gateway
- request external address from gateway to ensure it is connected to a WAN
- request port mapping from gateway
-
-
Constructor Summary
Constructors Constructor Description NatPmpPortMapping()
NatPmpPortMapping(AtomicBoolean externalAddressRequested, AtomicBoolean mappingRequested, int port, InetSocketAddressWrapper defaultGateway, InetAddress externalAddress, io.reactivex.rxjava3.disposables.Disposable timeoutGuard, io.reactivex.rxjava3.disposables.Disposable refreshTask, Runnable onFailure, Supplier<InetAddress> defaultGatewaySupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptMessage(AddressedByteBuf msg)
Is called for incoming messages and returns true if the message should be consumed and removed from the pipeline.void
handleMessage(HandlerContext ctx, AddressedByteBuf msg)
Is called for incoming messages and thus enables this method to react to relevant messages.void
start(HandlerContext ctx, NodeUpEvent event, Runnable onFailure)
Tells the method to create a port forwarding and renew it independently.void
stop(HandlerContext ctx)
Shall remove any existing port forwarding again.String
toString()
-
-
-
Field Detail
-
TIMEOUT
public static final Duration TIMEOUT
-
-
Constructor Detail
-
NatPmpPortMapping
public NatPmpPortMapping(AtomicBoolean externalAddressRequested, AtomicBoolean mappingRequested, int port, InetSocketAddressWrapper defaultGateway, InetAddress externalAddress, io.reactivex.rxjava3.disposables.Disposable timeoutGuard, io.reactivex.rxjava3.disposables.Disposable refreshTask, Runnable onFailure, Supplier<InetAddress> defaultGatewaySupplier)
-
NatPmpPortMapping
public NatPmpPortMapping()
-
-
Method Detail
-
start
public void start(HandlerContext ctx, NodeUpEvent event, Runnable onFailure)
Description copied from interface:PortMapping
Tells the method to create a port forwarding and renew it independently. If no forwarding can be created,onFailure
must be called once.- Specified by:
start
in interfacePortMapping
- Parameters:
ctx
- the handler contextevent
- the node up eventonFailure
- will be called once on failure
-
stop
public void stop(HandlerContext ctx)
Description copied from interface:PortMapping
Shall remove any existing port forwarding again.- Specified by:
stop
in interfacePortMapping
- Parameters:
ctx
- the handler context
-
acceptMessage
public boolean acceptMessage(AddressedByteBuf msg)
Description copied from interface:PortMapping
Is called for incoming messages and returns true if the message should be consumed and removed from the pipeline.- Specified by:
acceptMessage
in interfacePortMapping
- Parameters:
msg
- the message- Returns:
true
if the message is relevant for the current port forwarding method. Otherwisefalse
-
handleMessage
public void handleMessage(HandlerContext ctx, AddressedByteBuf msg)
Description copied from interface:PortMapping
Is called for incoming messages and thus enables this method to react to relevant messages.- Specified by:
handleMessage
in interfacePortMapping
- Parameters:
ctx
- the handler contextmsg
- the message
-
-