mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-11 22:09:32 +00:00
Remove nat none stategy
This commit is contained in:
parent
4a4941a593
commit
95d7f6882f
@ -157,7 +157,7 @@ type
|
||||
nat* {.
|
||||
desc:
|
||||
"Specify method to use for determining public address. " &
|
||||
"Must be one of: any, none, upnp, pmp, extip:<IP>. " &
|
||||
"Must be one of: any, upnp, pmp, extip:<IP>. " &
|
||||
"If connecting to peers on a local network only, use 'none'.",
|
||||
defaultValue: defaultNatConfig(),
|
||||
defaultValueDesc: "any",
|
||||
@ -407,8 +407,6 @@ func parse*(T: type NatConfig, p: string): Result[NatConfig, string] =
|
||||
case p.toLowerAscii
|
||||
of "any":
|
||||
return ok(NatConfig(hasExtIp: false, nat: NatStrategy.NatAny))
|
||||
of "none":
|
||||
return ok(NatConfig(hasExtIp: false, nat: NatStrategy.NatNone))
|
||||
of "upnp":
|
||||
return ok(NatConfig(hasExtIp: false, nat: NatStrategy.NatUpnp))
|
||||
of "pmp":
|
||||
|
||||
@ -48,7 +48,7 @@ type NatConfig* = object
|
||||
var
|
||||
upnp {.threadvar.}: Miniupnp
|
||||
npmp {.threadvar.}: NatPmp
|
||||
strategy = NatStrategy.NatNone
|
||||
strategy = NatStrategy.NatAny
|
||||
natClosed: Atomic[bool]
|
||||
extIp: Option[IpAddress]
|
||||
activeMappings: seq[PortMappings]
|
||||
@ -405,18 +405,6 @@ proc setupAddress*(
|
||||
return (prefSrcIp, some(tcpPort), some(udpPort))
|
||||
of PrefSrcIsPrivate, BindAddressIsPrivate:
|
||||
return setupNat(natConfig.nat, tcpPort, udpPort, clientId)
|
||||
of NatStrategy.NatNone:
|
||||
let (prefSrcIp, prefSrcStatus) = getRoutePrefSrc(bindIp)
|
||||
|
||||
case prefSrcStatus
|
||||
of NoRoutingInfo, PrefSrcIsPublic, BindAddressIsPublic:
|
||||
return (prefSrcIp, some(tcpPort), some(udpPort))
|
||||
of PrefSrcIsPrivate:
|
||||
error "No public IP address found. Should not use --nat:none option"
|
||||
return (none(IpAddress), some(tcpPort), some(udpPort))
|
||||
of BindAddressIsPrivate:
|
||||
error "Bind IP is not a public IP address. Should not use --nat:none option"
|
||||
return (none(IpAddress), some(tcpPort), some(udpPort))
|
||||
of NatStrategy.NatUpnp, NatStrategy.NatPmp:
|
||||
return setupNat(natConfig.nat, tcpPort, udpPort, clientId)
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ type NatStrategy* = enum
|
||||
NatAny
|
||||
NatUpnp
|
||||
NatPmp
|
||||
NatNone
|
||||
|
||||
func isGlobalUnicast*(address: TransportAddress): bool =
|
||||
if address.isGlobal() and address.isUnicast(): true else: false
|
||||
|
||||
@ -131,7 +131,6 @@ template multinodesuite*(suiteName: string, body: untyped) =
|
||||
config.addCliOption("--bootstrap-node", bootstrapNode)
|
||||
|
||||
config.addCliOption("--data-dir", datadir)
|
||||
config.addCliOption("--nat", "none")
|
||||
except StorageConfigError as e:
|
||||
raiseMultiNodeSuiteError "invalid cli option, error: " & e.msg
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ proc generateNodes*(
|
||||
if config.enableBootstrap:
|
||||
waitFor switch.peerInfo.update()
|
||||
let (announceAddrs, discoveryAddrs) = nattedAddress(
|
||||
NatConfig(hasExtIp: false, nat: NatNone),
|
||||
NatConfig(hasExtIp: false, nat: NatAny),
|
||||
switch.peerInfo.addrs,
|
||||
bindPort.Port,
|
||||
)
|
||||
|
||||
@ -64,29 +64,6 @@ suite "NAT Address Tests":
|
||||
check(discoveryAddrs == expectedDiscoveryAddrs)
|
||||
check(libp2pAddrs == expectedlibp2pAddrs)
|
||||
|
||||
suite "setupAddress":
|
||||
test "public bind IP with NatNone returns bind IP":
|
||||
let
|
||||
bindIp = parseIpAddress("8.8.8.8")
|
||||
natConfig = NatConfig(hasExtIp: false, nat: NatStrategy.NatNone)
|
||||
(ip, tcpPort, udpPort) =
|
||||
setupAddress(natConfig, bindIp, Port(5000), Port(5001), "test")
|
||||
|
||||
check ip == some(bindIp)
|
||||
check tcpPort == some(Port(5000))
|
||||
check udpPort == some(Port(5001))
|
||||
|
||||
test "private bind IP with NatNone returns no IP":
|
||||
let
|
||||
bindIp = parseIpAddress("192.168.1.1")
|
||||
natConfig = NatConfig(hasExtIp: false, nat: NatStrategy.NatNone)
|
||||
(ip, tcpPort, udpPort) =
|
||||
setupAddress(natConfig, bindIp, Port(5000), Port(5001), "test")
|
||||
|
||||
check ip == none(IpAddress)
|
||||
check tcpPort == some(Port(5000))
|
||||
check udpPort == some(Port(5001))
|
||||
|
||||
suite "getReachableAddresses":
|
||||
test "returns remapped addresses when extIp is configured":
|
||||
let
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user