mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-11 22:09:32 +00:00
Rename nat any to nat auto
This commit is contained in:
parent
95d7f6882f
commit
86708b545f
@ -157,10 +157,9 @@ type
|
||||
nat* {.
|
||||
desc:
|
||||
"Specify method to use for determining public address. " &
|
||||
"Must be one of: any, upnp, pmp, extip:<IP>. " &
|
||||
"If connecting to peers on a local network only, use 'none'.",
|
||||
"Must be one of: auto, upnp, pmp, extip:<IP>.",
|
||||
defaultValue: defaultNatConfig(),
|
||||
defaultValueDesc: "any",
|
||||
defaultValueDesc: "auto",
|
||||
name: "nat"
|
||||
.}: NatConfig
|
||||
|
||||
@ -329,7 +328,7 @@ func defaultAddress*(conf: StorageConf): IpAddress =
|
||||
result = static parseIpAddress("127.0.0.1")
|
||||
|
||||
func defaultNatConfig*(): NatConfig =
|
||||
result = NatConfig(hasExtIp: false, nat: NatStrategy.NatAny)
|
||||
result = NatConfig(hasExtIp: false, nat: NatStrategy.NatAuto)
|
||||
|
||||
proc getStorageVersion(): string =
|
||||
let tag = strip(staticExec("git describe --tags --abbrev=0"))
|
||||
@ -405,8 +404,8 @@ proc parseCmdArg*(T: type SignedPeerRecord, uri: string): T =
|
||||
|
||||
func parse*(T: type NatConfig, p: string): Result[NatConfig, string] =
|
||||
case p.toLowerAscii
|
||||
of "any":
|
||||
return ok(NatConfig(hasExtIp: false, nat: NatStrategy.NatAny))
|
||||
of "auto":
|
||||
return ok(NatConfig(hasExtIp: false, nat: NatStrategy.NatAuto))
|
||||
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.NatAny
|
||||
strategy = NatStrategy.NatAuto
|
||||
natClosed: Atomic[bool]
|
||||
extIp: Option[IpAddress]
|
||||
activeMappings: seq[PortMappings]
|
||||
@ -85,7 +85,7 @@ type DefaultNatMapper* = ref object of NatMapper
|
||||
proc getExternalIP*(natStrategy: NatStrategy, quiet = false): Option[IpAddress] =
|
||||
var externalIP: IpAddress
|
||||
|
||||
if natStrategy == NatStrategy.NatAny or natStrategy == NatStrategy.NatUpnp:
|
||||
if natStrategy == NatStrategy.NatAuto or natStrategy == NatStrategy.NatUpnp:
|
||||
if upnp == nil:
|
||||
upnp = newMiniupnp()
|
||||
|
||||
@ -127,7 +127,7 @@ proc getExternalIP*(natStrategy: NatStrategy, quiet = false): Option[IpAddress]
|
||||
error "parseIpAddress() exception", err = e.msg
|
||||
return
|
||||
|
||||
if natStrategy == NatStrategy.NatAny or natStrategy == NatStrategy.NatPmp:
|
||||
if natStrategy == NatStrategy.NatAuto or natStrategy == NatStrategy.NatPmp:
|
||||
if npmp == nil:
|
||||
npmp = newNatPmp()
|
||||
let nres = npmp.init()
|
||||
@ -397,7 +397,7 @@ proc setupAddress*(
|
||||
return (some(natConfig.extIp), some(tcpPort), some(udpPort))
|
||||
|
||||
case natConfig.nat
|
||||
of NatStrategy.NatAny:
|
||||
of NatStrategy.NatAuto:
|
||||
let (prefSrcIp, prefSrcStatus) = getRoutePrefSrc(bindIp)
|
||||
|
||||
case prefSrcStatus
|
||||
|
||||
@ -5,7 +5,7 @@ import std/[net, tables, hashes, options], pkg/results, chronos, chronicles
|
||||
import pkg/libp2p
|
||||
|
||||
type NatStrategy* = enum
|
||||
NatAny
|
||||
NatAuto
|
||||
NatUpnp
|
||||
NatPmp
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ proc generateNodes*(
|
||||
if config.enableBootstrap:
|
||||
waitFor switch.peerInfo.update()
|
||||
let (announceAddrs, discoveryAddrs) = nattedAddress(
|
||||
NatConfig(hasExtIp: false, nat: NatAny),
|
||||
NatConfig(hasExtIp: false, nat: NatAuto),
|
||||
switch.peerInfo.addrs,
|
||||
bindPort.Port,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user