mirror of
https://github.com/logos-storage/nim-libplum.git
synced 2026-06-07 17:49:25 +00:00
Format code
This commit is contained in:
parent
73b555bca7
commit
5c28d21f20
@ -54,12 +54,13 @@ when miniupnp_protocol != "":
|
|||||||
let mappingTimeout = seconds(40)
|
let mappingTimeout = seconds(40)
|
||||||
|
|
||||||
let logLevel =
|
let logLevel =
|
||||||
if getEnv("LIBPLUM_VERBOSE") == "1": PLUM_LOG_LEVEL_VERBOSE
|
if getEnv("LIBPLUM_VERBOSE") == "1": PLUM_LOG_LEVEL_VERBOSE else: PLUM_LOG_LEVEL_NONE
|
||||||
else: PLUM_LOG_LEVEL_NONE
|
|
||||||
|
|
||||||
var gRenewed: Atomic[bool]
|
var gRenewed: Atomic[bool]
|
||||||
|
|
||||||
proc onMappingRenewal(state: PlumState, mapping: PlumMapping) {.cdecl, raises: [], gcsafe.} =
|
proc onMappingRenewal(
|
||||||
|
state: PlumState, mapping: PlumMapping
|
||||||
|
) {.cdecl, raises: [], gcsafe.} =
|
||||||
if state == Success:
|
if state == Success:
|
||||||
gRenewed.store(true)
|
gRenewed.store(true)
|
||||||
|
|
||||||
@ -80,8 +81,7 @@ when miniupnp_protocol != "":
|
|||||||
let pidFile = "/tmp/plum-test/miniupnpd-" & proto & ".pid"
|
let pidFile = "/tmp/plum-test/miniupnpd-" & proto & ".pid"
|
||||||
let confFile = "/tmp/plum-test/miniupnpd-" & proto & ".conf"
|
let confFile = "/tmp/plum-test/miniupnpd-" & proto & ".conf"
|
||||||
let logFile = "/tmp/plum-test/miniupnpd-" & proto & ".log"
|
let logFile = "/tmp/plum-test/miniupnpd-" & proto & ".log"
|
||||||
let binary =
|
let binary = if proto == "natpmp": "miniupnpd-natpmponly" else: "miniupnpd"
|
||||||
if proto == "natpmp": "miniupnpd-natpmponly" else: "miniupnpd"
|
|
||||||
|
|
||||||
discard execShellCmd(
|
discard execShellCmd(
|
||||||
binary & " -d -f " & confFile & " >> " & logFile & " 2>&1 & echo $! > " & pidFile
|
binary & " -d -f " & confFile & " >> " & logFile & " 2>&1 & echo $! > " & pidFile
|
||||||
@ -90,14 +90,17 @@ when miniupnp_protocol != "":
|
|||||||
suite "plum - " & miniupnp_protocol & " using miniupnp":
|
suite "plum - " & miniupnp_protocol & " using miniupnp":
|
||||||
test "createMapping TCP and destroyMapping":
|
test "createMapping TCP and destroyMapping":
|
||||||
require init(discoverTimeout = discoverMs, logLevel = logLevel).isOk()
|
require init(discoverTimeout = discoverMs, logLevel = logLevel).isOk()
|
||||||
defer: discard cleanup()
|
defer:
|
||||||
|
discard cleanup()
|
||||||
|
|
||||||
let r = waitFor createMapping(TCP, 8101, timeout = mappingTimeout)
|
let r = waitFor createMapping(TCP, 8101, timeout = mappingTimeout)
|
||||||
require r.isOk()
|
require r.isOk()
|
||||||
let res = r.value
|
let res = r.value
|
||||||
defer: destroyMapping(res.id)
|
defer:
|
||||||
|
destroyMapping(res.id)
|
||||||
|
|
||||||
checkpoint miniupnp_protocol & " TCP: " & res.mapping.externalHost & ":" & $res.mapping.externalPort
|
checkpoint miniupnp_protocol & " TCP: " & res.mapping.externalHost & ":" &
|
||||||
|
$res.mapping.externalPort
|
||||||
check res.mapping.externalPort > 0
|
check res.mapping.externalPort > 0
|
||||||
check res.mapping.externalHost.len > 0
|
check res.mapping.externalHost.len > 0
|
||||||
check hasMapping(res.id)
|
check hasMapping(res.id)
|
||||||
@ -111,15 +114,18 @@ when miniupnp_protocol != "":
|
|||||||
|
|
||||||
test "createMapping UDP and destroying":
|
test "createMapping UDP and destroying":
|
||||||
require init(discoverTimeout = discoverMs, logLevel = logLevel).isOk()
|
require init(discoverTimeout = discoverMs, logLevel = logLevel).isOk()
|
||||||
defer: discard cleanup()
|
defer:
|
||||||
|
discard cleanup()
|
||||||
|
|
||||||
let r = waitFor createMapping(UDP, 8090, timeout = mappingTimeout)
|
let r = waitFor createMapping(UDP, 8090, timeout = mappingTimeout)
|
||||||
require r.isOk()
|
require r.isOk()
|
||||||
|
|
||||||
let res = r.value
|
let res = r.value
|
||||||
defer: destroyMapping(res.id)
|
defer:
|
||||||
|
destroyMapping(res.id)
|
||||||
|
|
||||||
checkpoint miniupnp_protocol & " UDP: " & res.mapping.externalHost & ":" & $res.mapping.externalPort
|
checkpoint miniupnp_protocol & " UDP: " & res.mapping.externalHost & ":" &
|
||||||
|
$res.mapping.externalPort
|
||||||
check res.mapping.externalPort > 0
|
check res.mapping.externalPort > 0
|
||||||
|
|
||||||
when miniupnp_protocol == "upnp":
|
when miniupnp_protocol == "upnp":
|
||||||
@ -131,10 +137,11 @@ when miniupnp_protocol != "":
|
|||||||
|
|
||||||
test "mapping is renewed after miniupnpd restart":
|
test "mapping is renewed after miniupnpd restart":
|
||||||
require init(
|
require init(
|
||||||
discoverTimeout = discoverMs, logLevel = logLevel,
|
discoverTimeout = discoverMs, logLevel = logLevel, recheckPeriod = recheckMs
|
||||||
recheckPeriod = recheckMs,
|
)
|
||||||
).isOk()
|
.isOk()
|
||||||
defer: discard cleanup()
|
defer:
|
||||||
|
discard cleanup()
|
||||||
|
|
||||||
gRenewed.store(false)
|
gRenewed.store(false)
|
||||||
|
|
||||||
@ -143,7 +150,8 @@ when miniupnp_protocol != "":
|
|||||||
)
|
)
|
||||||
require r.isOk()
|
require r.isOk()
|
||||||
let res = r.value
|
let res = r.value
|
||||||
defer: destroyMapping(res.id)
|
defer:
|
||||||
|
destroyMapping(res.id)
|
||||||
|
|
||||||
when miniupnp_protocol == "natpmp":
|
when miniupnp_protocol == "natpmp":
|
||||||
# Let the server epoch advance so the restart is detectable
|
# Let the server epoch advance so the restart is detectable
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user