From 409d771a50162a94152f16ca2a590f1bcd9812d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 18 Jul 2019 00:50:16 +0200 Subject: [PATCH] metrics: put the HTTP server under -d:insecure - also fix an option parsing bug - bump vendor/nim-eth and vendor/nim-metrics --- nimbus/config.nim | 22 ++++++++++++++++------ nimbus/nimbus.nim | 9 +++++---- vendor/nim-eth | 2 +- vendor/nim-metrics | 2 +- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/nimbus/config.nim b/nimbus/config.nim index 3b3616df0..2449b891d 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -497,9 +497,9 @@ proc processNetArguments(key, value: string): ConfigStatus = result = processInteger(value, res) if result == Success: config.net.discPort = uint16(res and 0xFFFF) - elif skey == "metricsserver": + elif skey == "metricsserver" and defined(insecure): config.net.metricsServer = true - elif skey == "metricsserverport": + elif skey == "metricsserverport" and defined(insecure): var res = 0 result = processInteger(value, res) if result == Success: @@ -602,6 +602,8 @@ proc processDebugArguments(key, value: string): ConfigStatus = result = processInteger(value, res) if result == Success: config.debug.logMetricsInterval = res + else: + result = EmptyOption proc dumpConfiguration*(): string = ## Dumps current configuration as string @@ -680,6 +682,14 @@ proc getHelpString*(): string = continue logLevels.add($level) + when defined(insecure): + let metricsServerHelp = """ + + --metricsServer Enable the metrics HTTP server + --metricsServerPort: Metrics HTTP server port on localhost (default: 9093)""" + else: + let metricsServerHelp = "" + result = """ USAGE: @@ -696,9 +706,7 @@ NETWORKING OPTIONS: --bootnodesv5: Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes) --staticnodes: Comma separated enode URLs to connect with --port: Network listening TCP port (default: 30303) - --discport: Network listening UDP port (defaults to --port argument) - --metricsServer Enable the metrics HTTP server - --metricsServerPort: Metrics HTTP server port on localhost (default: 9093) + --discport: Network listening UDP port (defaults to --port argument)$7 --maxpeers: Maximum number of network peers (default: 25) --maxpendpeers: Maximum number of pending connection attempts (default: 0) --nat: NAT port mapping mechanism (any|none|upnp|pmp|) (default: "any") @@ -737,7 +745,8 @@ LOGGING AND DEBUGGING OPTIONS: $defaultLogLevel, strip($defaultProtocols, chars = {'{','}'}), $defaultMaxMsgSize, - $defaultMinPow + $defaultMinPow, + metricsServerHelp, ] proc processArguments*(msg: var string): ConfigStatus = @@ -783,6 +792,7 @@ proc processArguments*(msg: var string): ConfigStatus = processArgument processDebugArguments, key, value, msg if result != Success: msg = "Unknown option: '" & key & "'." + break of cmdEnd: doAssert(false) # we're never getting this kind here diff --git a/nimbus/nimbus.nim b/nimbus/nimbus.nim index 8f1c380ef..9224a24e2 100644 --- a/nimbus/nimbus.nim +++ b/nimbus/nimbus.nim @@ -146,10 +146,11 @@ proc start() = nimbus.rpcServer.start() # metrics server - if conf.net.metricsServer: - let metricsAddress = "127.0.0.1" - info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort - metrics.startHttpServer(metricsAddress, Port(conf.net.metricsServerPort)) + when defined(insecure): + if conf.net.metricsServer: + let metricsAddress = "127.0.0.1" + info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsServerPort + metrics.startHttpServer(metricsAddress, Port(conf.net.metricsServerPort)) # Connect directly to the static nodes for enode in conf.net.staticNodes: diff --git a/vendor/nim-eth b/vendor/nim-eth index 0a5ffaa8b..e195868a6 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 0a5ffaa8b35dacbb3992879667ea5ce37690b7dd +Subproject commit e195868a64bb3b2a4381db3a030298bc1ec626eb diff --git a/vendor/nim-metrics b/vendor/nim-metrics index dc98c44cd..169c27df6 160000 --- a/vendor/nim-metrics +++ b/vendor/nim-metrics @@ -1 +1 @@ -Subproject commit dc98c44cdff1a23d5f364727854e875948eac158 +Subproject commit 169c27df6ed899dbe28bb1b7751fb5f2d937c6d0