mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-03-02 02:13:07 +00:00
feat(cli)!: change --listen-addrs to --listen-port
This allows specifying the port only for the listening address, the address that is announced on the DHT for peer connections. It makes the developer experience less confusing, and easier to change for things like port forwarding. # Conflicts: # storage/storage.nim # tests/integration/multinodes.nim
This commit is contained in:
parent
ab413bdfcf
commit
04f7c6cfd5
@ -240,7 +240,8 @@ paths:
|
||||
description: |
|
||||
If supplied, it will be used to dial the peer.
|
||||
The address has to target the listening address of the peer,
|
||||
which is specified with the `--listen-addrs` CLI flag.
|
||||
which is /ip4/0.0.0.0/tcp/<port>, where port is specified
|
||||
with the `--listen-port` CLI flag.
|
||||
|
||||
responses:
|
||||
"200":
|
||||
|
||||
@ -135,14 +135,13 @@ type
|
||||
name: "data-dir"
|
||||
.}: OutDir
|
||||
|
||||
listenAddrs* {.
|
||||
desc: "Multi Addresses to listen on",
|
||||
defaultValue:
|
||||
@[MultiAddress.init("/ip4/0.0.0.0/tcp/0").expect("Should init multiaddress")],
|
||||
defaultValueDesc: "/ip4/0.0.0.0/tcp/0",
|
||||
abbr: "i",
|
||||
name: "listen-addrs"
|
||||
.}: seq[MultiAddress]
|
||||
listenPort* {.
|
||||
desc: "Port to listen on for remote peer connections. Announced in the DHT as /ip4/0.0.0.0/tcp/",
|
||||
defaultValue: 0,
|
||||
defaultValueDesc: "Chooses a random port for the MultiAddress, eg /ip4/0.0.0.0/tcp/0",
|
||||
abbr: "l",
|
||||
name: "listen-port"
|
||||
.}: int
|
||||
|
||||
nat* {.
|
||||
desc:
|
||||
|
||||
@ -440,7 +440,9 @@ proc initNodeApi(node: StorageNodeRef, conf: StorageConf, router: var RestRouter
|
||||
## to invoke peer discovery, if it succeeds
|
||||
## the returned addresses will be used to dial
|
||||
##
|
||||
## `addrs` the listening addresses of the peers to dial, eg the one specified with `--listen-addrs`
|
||||
## `addrs` the listening addresses of the peers to dial, which is
|
||||
## /ip4/0.0.0.0/tcp/<port>, where port is specified with the
|
||||
## `--listen-port` CLI flag.
|
||||
##
|
||||
var headers = buildCorsHeaders("GET", allowedOrigin)
|
||||
|
||||
|
||||
@ -139,10 +139,14 @@ proc new*(
|
||||
T: type StorageServer, config: StorageConf, privateKey: StoragePrivateKey
|
||||
): StorageServer =
|
||||
## create StorageServer including setting up datastore, repostore, etc
|
||||
let listenAddr = MultiAddress
|
||||
.init(DefaultListenAddress & $config.listenPort)
|
||||
.expect("Default multiaddress and provied port not valid")
|
||||
|
||||
let switch = SwitchBuilder
|
||||
.new()
|
||||
.withPrivateKey(privateKey)
|
||||
.withAddresses(config.listenAddrs)
|
||||
.withAddresses(@[listenAddr])
|
||||
.withRng(random.Rng.instance())
|
||||
.withNoise()
|
||||
.withMplex(5.minutes, 5.minutes)
|
||||
@ -190,7 +194,7 @@ proc new*(
|
||||
|
||||
discovery = Discovery.new(
|
||||
switch.peerInfo.privateKey,
|
||||
announceAddrs = config.listenAddrs,
|
||||
announceAddrs = @[listenAddr],
|
||||
bindPort = config.discoveryPort,
|
||||
bootstrapNodes = config.bootstrapNodes,
|
||||
store = discoveryStore,
|
||||
|
||||
@ -135,7 +135,6 @@ template multinodesuite*(suiteName: string, body: untyped) =
|
||||
|
||||
config.addCliOption("--data-dir", datadir)
|
||||
config.addCliOption("--nat", "none")
|
||||
config.addCliOption("--listen-addrs", "/ip4/127.0.0.1/tcp/0")
|
||||
except StorageConfigError as e:
|
||||
raiseMultiNodeSuiteError "invalid cli option, error: " & e.msg
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user