2019-12-12 18:40:34 +00:00
|
|
|
import
|
2019-12-13 16:04:08 +00:00
|
|
|
confutils/defs, chronicles, chronos,
|
|
|
|
eth/keys, eth/p2p/rlpx_protocols/waku_protocol
|
2019-12-12 18:40:34 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
Fleet* = enum
|
|
|
|
none
|
|
|
|
beta
|
|
|
|
staging
|
|
|
|
|
|
|
|
WakuNodeConf* = object
|
|
|
|
logLevel* {.
|
|
|
|
desc: "Sets the log level."
|
|
|
|
defaultValue: LogLevel.INFO
|
|
|
|
name: "log-level" }: LogLevel
|
|
|
|
|
|
|
|
tcpPort* {.
|
|
|
|
desc: "TCP listening port."
|
|
|
|
defaultValue: 30303
|
|
|
|
name: "tcp-port" }: uint16
|
|
|
|
|
|
|
|
udpPort* {.
|
|
|
|
desc: "UDP listening port."
|
|
|
|
defaultValue: 30303
|
2019-12-16 15:35:03 +00:00
|
|
|
name: "udp-port" }: uint16
|
|
|
|
|
|
|
|
portsShift* {.
|
|
|
|
desc: "Add a shift to all port numbers."
|
|
|
|
defaultValue: 0
|
|
|
|
name: "ports-shift" }: uint16
|
2019-12-12 18:40:34 +00:00
|
|
|
|
|
|
|
discovery* {.
|
|
|
|
desc: "Enable/disable discovery v4."
|
|
|
|
defaultValue: true
|
|
|
|
name: "discovery" }: bool
|
|
|
|
|
|
|
|
noListen* {.
|
|
|
|
desc: "Disable listening for incoming peers."
|
|
|
|
defaultValue: false
|
|
|
|
name: "no-listen" }: bool
|
|
|
|
|
|
|
|
fleet* {.
|
|
|
|
desc: "Select the fleet to connect to."
|
|
|
|
defaultValue: Fleet.none
|
|
|
|
name: "fleet" }: Fleet
|
|
|
|
|
|
|
|
bootnodes* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "Comma separated enode URLs for P2P discovery bootstrap."
|
2019-12-12 18:40:34 +00:00
|
|
|
name: "bootnodes" }: seq[string]
|
|
|
|
|
|
|
|
staticnodes* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "Comma separated enode URLs to directly connect with."
|
2019-12-12 18:40:34 +00:00
|
|
|
name: "staticnodes" }: seq[string]
|
|
|
|
|
|
|
|
whisper* {.
|
|
|
|
desc: "Enable the Whisper protocol."
|
|
|
|
defaultValue: false
|
|
|
|
name: "whisper" }: bool
|
|
|
|
|
|
|
|
whisperBridge* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "Enable the Whisper protocol and bridge with Waku protocol."
|
2019-12-12 18:40:34 +00:00
|
|
|
defaultValue: false
|
|
|
|
name: "whisper-bridge" }: bool
|
|
|
|
|
2020-01-14 22:35:47 +00:00
|
|
|
lightNode* {.
|
|
|
|
desc: "Run as light node (no message relay).",
|
|
|
|
defaultValue: false
|
|
|
|
name: "light-node" }: bool
|
|
|
|
|
2019-12-17 23:26:53 +00:00
|
|
|
wakuMode* {.
|
|
|
|
desc: "Select the Waku mode.",
|
|
|
|
defaultValue: WakuSan
|
|
|
|
name: "waku-mode" }: WakuMode
|
|
|
|
|
|
|
|
wakuPow* {.
|
|
|
|
desc: "PoW requirement of Waku node.",
|
|
|
|
defaultValue: 0.002
|
|
|
|
name: "waku-pow" }: float64
|
|
|
|
|
2019-12-12 18:40:34 +00:00
|
|
|
nodekey* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "P2P node private key as hex.",
|
2019-12-12 18:40:34 +00:00
|
|
|
defaultValue: newKeyPair()
|
|
|
|
name: "nodekey" }: KeyPair
|
|
|
|
# TODO: Add nodekey file option
|
|
|
|
|
|
|
|
bootnodeOnly* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "Run only as discovery bootnode."
|
2019-12-12 18:40:34 +00:00
|
|
|
defaultValue: false
|
|
|
|
name: "bootnode-only" }: bool
|
|
|
|
|
|
|
|
rpc* {.
|
2019-12-16 15:35:03 +00:00
|
|
|
desc: "Enable Waku RPC server.",
|
2019-12-12 18:40:34 +00:00
|
|
|
defaultValue: false
|
|
|
|
name: "rpc" }: bool
|
|
|
|
|
2019-12-16 15:35:03 +00:00
|
|
|
rpcAddress* {.
|
|
|
|
desc: "Listening address of the RPC server.",
|
|
|
|
defaultValue: parseIpAddress("127.0.0.1")
|
|
|
|
name: "rpc-address" }: IpAddress
|
|
|
|
|
|
|
|
rpcPort* {.
|
|
|
|
desc: "Listening port of the RPC server.",
|
|
|
|
defaultValue: 8545
|
|
|
|
name: "rpc-port" }: uint16
|
2019-12-12 18:40:34 +00:00
|
|
|
|
2019-12-17 23:26:53 +00:00
|
|
|
metricsServer* {.
|
|
|
|
desc: "Enable the metrics server."
|
|
|
|
defaultValue: false
|
|
|
|
name: "metrics-server" }: bool
|
2019-12-13 16:04:08 +00:00
|
|
|
|
2019-12-17 23:26:53 +00:00
|
|
|
metricsServerAddress* {.
|
|
|
|
desc: "Listening address of the metrics server."
|
|
|
|
defaultValue: parseIpAddress("127.0.0.1")
|
|
|
|
name: "metrics-server-address" }: IpAddress
|
|
|
|
|
|
|
|
metricsServerPort* {.
|
|
|
|
desc: "Listening HTTP port of the metrics server."
|
|
|
|
defaultValue: 8008
|
|
|
|
name: "metrics-server-port" }: uint16
|
2019-12-13 16:04:08 +00:00
|
|
|
|
2020-01-14 22:35:47 +00:00
|
|
|
logMetrics* {.
|
|
|
|
desc: "Enable metrics logging."
|
|
|
|
defaultValue: false
|
|
|
|
name: "log-metrics" }: bool
|
|
|
|
|
2019-12-12 18:40:34 +00:00
|
|
|
# TODO:
|
|
|
|
# - nat
|
|
|
|
# - discv5 + topic register
|
|
|
|
# - mailserver functionality
|
|
|
|
|
|
|
|
proc parseCmdArg*(T: type KeyPair, p: TaintedString): T =
|
|
|
|
try:
|
|
|
|
# TODO: add isValidPrivateKey check from Nimbus?
|
|
|
|
result.seckey = initPrivateKey(p)
|
|
|
|
result.pubkey = result.seckey.getPublicKey()
|
|
|
|
except CatchableError as e:
|
|
|
|
raise newException(ConfigurationError, "Invalid private key")
|
|
|
|
|
|
|
|
proc completeCmdArg*(T: type KeyPair, val: TaintedString): seq[string] =
|
|
|
|
return @[]
|
2019-12-16 15:35:03 +00:00
|
|
|
|
|
|
|
proc parseCmdArg*(T: type IpAddress, p: TaintedString): T =
|
|
|
|
try:
|
|
|
|
result = parseIpAddress(p)
|
|
|
|
except CatchableError as e:
|
|
|
|
raise newException(ConfigurationError, "Invalid IP address")
|
|
|
|
|
|
|
|
proc completeCmdArg*(T: type IpAddress, val: TaintedString): seq[string] =
|
|
|
|
return @[]
|