mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-29 05:49:26 +00:00
Define autonat interval
This commit is contained in:
parent
858fae7154
commit
c95d48ee24
@ -19,7 +19,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withRelay(0)
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
test "node is reachable when using bootstrap node on same network", natConfig:
|
||||
@ -33,7 +33,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 1, "endpoint-independent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# EIF = Endpoint Independent Filtering
|
||||
@ -48,7 +48,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 1, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# APDF = Address and Port-Dependent Filtering
|
||||
@ -64,7 +64,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 1, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(5.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# APDF = Address and Port-Dependent Filtering
|
||||
@ -74,9 +74,7 @@ multinodesuite "AutoNAT detection":
|
||||
let node2 = clients()[1]
|
||||
|
||||
await node2.client.checkNotReachable()
|
||||
|
||||
check (await node2.client.setNatFiltering("endpoint-independent")).isOk
|
||||
|
||||
await node2.client.checkReachable()
|
||||
|
||||
let natToSimConfig = NodeConfigs(
|
||||
@ -86,7 +84,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 1, "endpoint-independent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(5.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# APDF = Address and Port-Dependent Filtering
|
||||
@ -95,9 +93,7 @@ multinodesuite "AutoNAT detection":
|
||||
let node2 = clients()[1]
|
||||
|
||||
await node2.client.checkReachable()
|
||||
|
||||
check (await node2.client.setNatFiltering("address-and-port-dependent")).isOk
|
||||
|
||||
await node2.client.checkNotReachable()
|
||||
|
||||
let doubleNatConfig = NodeConfigs(
|
||||
@ -107,7 +103,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 1, "double-nat")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(5.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
test "node behind double NAT is detected as not reachable and starts relay",
|
||||
@ -123,7 +119,7 @@ multinodesuite "AutoNAT detection":
|
||||
.withNatSimulation(idx = 2, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(5.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# APDF = Address and Port-Dependent Filtering
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import std/json
|
||||
import std/[json, sequtils]
|
||||
import pkg/chronos
|
||||
import pkg/questionable/results
|
||||
|
||||
import ../multinodes
|
||||
import ../storageclient
|
||||
import ../storageconfig
|
||||
import ../nathelper
|
||||
|
||||
const
|
||||
RelayTimeout = 30_000
|
||||
@ -18,7 +19,7 @@ multinodesuite "NAT download":
|
||||
.withNatSimulation(idx = 2, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(5.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
# APDF = Address and Port-Dependent Filtering
|
||||
@ -50,6 +51,13 @@ multinodesuite "NAT download":
|
||||
pollInterval = PollInterval,
|
||||
)
|
||||
|
||||
# Verify natNode advertises a relay circuit address. seed has never dialed
|
||||
# natNode, so APDF blocks any direct inbound connection from seed — the
|
||||
# only reachable address is the p2p-circuit one.
|
||||
let info = (await natNode.client.info()).get
|
||||
let addrs = info["addrs"].getElems.mapIt(it.getStr)
|
||||
check addrs.anyIt("p2p-circuit" in it)
|
||||
|
||||
let content = "content seeded from nat node"
|
||||
let cid = (await natNode.client.upload(content)).get
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import ./storageconfig
|
||||
const
|
||||
RelayTimeout* = 30_000
|
||||
PollInterval* = 1_000
|
||||
NatScheduleInterval* = 5.seconds
|
||||
|
||||
proc checkNatStatus*(
|
||||
client: StorageClient, reachability: string, relayRunning: bool, clientMode: bool
|
||||
@ -43,6 +44,8 @@ proc checkNatStatus*(
|
||||
proc checkReachable*(client: StorageClient) {.async.} =
|
||||
await client.checkNatStatus("Reachable", relayRunning = false, clientMode = false)
|
||||
|
||||
# Relay might be false when the mapping has been created for UPnP / TCP but
|
||||
# Autonat didn't detect yet Reachable
|
||||
proc checkNotReachable*(client: StorageClient, relayRunning = true) {.async.} =
|
||||
await client.checkNatStatus(
|
||||
"NotReachable", relayRunning = relayRunning, clientMode = true
|
||||
|
||||
@ -16,7 +16,7 @@ multinodesuite "AutoNAT PCP port mapping":
|
||||
.withNatSimulation(idx = 1, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
|
||||
@ -44,7 +44,7 @@ multinodesuite "AutoNAT PCP port mapping":
|
||||
.withNatSimulation(idx = 1, "double-nat")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
# Increase the max queue to trigger the AutoNat 2 times
|
||||
.withNatMaxQueueSize(2).some
|
||||
)
|
||||
@ -63,6 +63,9 @@ multinodesuite "AutoNAT PCP port mapping":
|
||||
pollInterval = PollInterval,
|
||||
)
|
||||
|
||||
# Wait for next Autonat iteration
|
||||
await sleepAsync(6.seconds)
|
||||
|
||||
await node2.client.checkNotReachable()
|
||||
|
||||
test "reachable node downloads content uploaded by node behind NAT after PCP mapping",
|
||||
|
||||
@ -16,7 +16,7 @@ multinodesuite "AutoNAT UPnP port mapping":
|
||||
.withNatSimulation(idx = 1, "address-and-port-dependent")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
.withNatMaxQueueSize(1).some
|
||||
)
|
||||
|
||||
@ -45,7 +45,7 @@ multinodesuite "AutoNAT UPnP port mapping":
|
||||
.withNatSimulation(idx = 1, "double-nat")
|
||||
.withNatNumPeersToAsk(1)
|
||||
.withNatMinConfidence(0.5)
|
||||
.withNatScheduleInterval(10.seconds)
|
||||
.withNatScheduleInterval(NatScheduleInterval)
|
||||
# Increase the max queue to trigger the AutoNat 2 times
|
||||
.withNatMaxQueueSize(2).some
|
||||
)
|
||||
@ -64,6 +64,9 @@ multinodesuite "AutoNAT UPnP port mapping":
|
||||
pollInterval = PollInterval,
|
||||
)
|
||||
|
||||
# Wait for next Autonat iteration
|
||||
await sleepAsync(6.seconds)
|
||||
|
||||
await node2.client.checkNotReachable()
|
||||
|
||||
test "reachable node downloads content uploaded by node behind NAT after UPnP mapping",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user