mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-13 05:59:36 +00:00
feat: add a warning when private address only (#1423)
Signed-off-by: Arnaud <arno.deville@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
8dd2356000
commit
4c9ecd0766
@ -91,6 +91,6 @@ Feel free to dive in, contributions are welcomed! Open an issue or submit PRs.
|
||||
|
||||
`logos-storage-nim` uses [nph](https://github.com/arnetheduck/nph) for formatting our code and it is required to adhere to its styling.
|
||||
If you are setting up fresh setup, in order to get `nph` run `make build-nph`.
|
||||
In order to format files run `make nph/<file/folder you want to format>`.
|
||||
If you want you can install Git pre-commit hook using `make install-nph-commit`, which will format modified files prior committing them.
|
||||
If you are using VSCode and the [NimLang](https://marketplace.visualstudio.com/items?itemName=NimLang.nimlang) extension you can enable "Format On Save" (eq. the `nim.formatOnSave` property) that will format the files using `nph`.
|
||||
In order to format files run `make nph/<file/folder you want to format>`.
|
||||
If you want you can install Git pre-commit hook using `make install-nph-commit`, which will format modified files prior committing them.
|
||||
If you are using VSCode and the [NimLang](https://marketplace.visualstudio.com/items?itemName=NimLang.nimlang) extension you can enable "Format On Save" (eq. the `nim.formatOnSave` property) that will format the files using `nph`.
|
||||
|
||||
@ -91,6 +91,7 @@ proc createStorage(
|
||||
configJson: cstring
|
||||
): Future[Result[StorageServer, string]] {.async: (raises: []).} =
|
||||
var conf: StorageConf
|
||||
|
||||
try:
|
||||
conf = StorageConf.load(
|
||||
version = storageFullVersion,
|
||||
@ -185,6 +186,6 @@ proc process*(
|
||||
try:
|
||||
await storage[].close()
|
||||
except Exception as e:
|
||||
error "Failed to STOP_NODE.", error = e.msg
|
||||
error "Failed to CLOSE_NODE.", error = e.msg
|
||||
return err(e.msg)
|
||||
return ok("")
|
||||
|
||||
@ -11,6 +11,7 @@ import std/os
|
||||
import std/tables
|
||||
import std/cpuinfo
|
||||
import std/net
|
||||
import std/sequtils
|
||||
|
||||
import pkg/chronos
|
||||
import pkg/taskpools
|
||||
@ -31,6 +32,7 @@ import ./blockexchange
|
||||
import ./utils/fileutils
|
||||
import ./discovery
|
||||
import ./utils/addrutils
|
||||
import ./utils/natutils
|
||||
import ./namespaces
|
||||
import ./storagetypes
|
||||
import ./logutils
|
||||
@ -77,6 +79,16 @@ proc start*(s: StorageServer) {.async.} =
|
||||
s.config.nat, s.storageNode.switch.peerInfo.addrs, s.config.discoveryPort
|
||||
)
|
||||
|
||||
var hasPublicAddr = false
|
||||
for announceAddr in announceAddrs:
|
||||
let (maybeIp, _) = getAddressAndPort(announceAddr)
|
||||
if maybeIp.isSome and maybeIp.get.isGlobalUnicast():
|
||||
hasPublicAddr = true
|
||||
break
|
||||
|
||||
if not hasPublicAddr:
|
||||
warn "Unable to determine a public IP address. This node will only be reachable on a private network."
|
||||
|
||||
s.storageNode.discovery.updateAnnounceRecord(announceAddrs)
|
||||
s.storageNode.discovery.updateDhtRecord(discoveryAddrs)
|
||||
|
||||
@ -110,7 +122,10 @@ proc stop*(s: StorageServer) {.async.} =
|
||||
|
||||
if res.failure.len > 0:
|
||||
error "Failed to stop Storage node", failures = res.failure.len
|
||||
raiseAssert "Failed to stop Storage node"
|
||||
raise newException(
|
||||
StorageError,
|
||||
"Failed to stop Storage node: " & res.failure.mapIt(it.error.msg).join(", "),
|
||||
)
|
||||
|
||||
proc close*(s: StorageServer) {.async.} =
|
||||
var futures =
|
||||
@ -123,7 +138,7 @@ proc close*(s: StorageServer) {.async.} =
|
||||
s.taskpool.shutdown()
|
||||
except Exception as exc:
|
||||
error "Failed to stop the taskpool", failures = res.failure.len
|
||||
raiseAssert("Failure in taskpool shutdown:" & exc.msg)
|
||||
raise newException(StorageError, "Failure in taskpool shutdown: " & exc.msg)
|
||||
|
||||
when defaultChroniclesStream.outputs.type.arity >= 3:
|
||||
proc noOutput(logLevel: LogLevel, msg: LogOutputStr) =
|
||||
@ -137,7 +152,10 @@ proc close*(s: StorageServer) {.async.} =
|
||||
|
||||
if res.failure.len > 0:
|
||||
error "Failed to close Storage node", failures = res.failure.len
|
||||
raiseAssert "Failed to close Storage node"
|
||||
raise newException(
|
||||
StorageError,
|
||||
"Failed to close Storage node: " & res.failure.mapIt(it.error.msg).join(", "),
|
||||
)
|
||||
|
||||
proc shutdown*(server: StorageServer) {.async.} =
|
||||
await server.stop()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user