feat: use env. variables for arguments

This commit is contained in:
Richard Ramos 2023-01-03 15:51:43 -04:00 committed by RichΛrd
parent 49a35e8168
commit 26daf72a23
2 changed files with 75 additions and 6 deletions

View File

@ -14,6 +14,7 @@ var (
Value: 60000, Value: 60000,
Usage: "Libp2p TCP listening port (0 for random)", Usage: "Libp2p TCP listening port (0 for random)",
Destination: &options.Port, Destination: &options.Port,
EnvVars: []string{"WAKUNODE2_TCP_PORT"},
} }
Address = &cli.StringFlag{ Address = &cli.StringFlag{
Name: "address", Name: "address",
@ -21,12 +22,14 @@ var (
Value: "0.0.0.0", Value: "0.0.0.0",
Usage: "Listening address", Usage: "Listening address",
Destination: &options.Address, Destination: &options.Address,
EnvVars: []string{"WAKUNODE2_ADDRESS"},
} }
WebsocketSupport = &cli.BoolFlag{ WebsocketSupport = &cli.BoolFlag{
Name: "websocket-support", Name: "websocket-support",
Aliases: []string{"ws"}, Aliases: []string{"ws"},
Usage: "Enable websockets support", Usage: "Enable websockets support",
Destination: &options.Websocket.Enable, Destination: &options.Websocket.Enable,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_SUPPORT"},
} }
WebsocketPort = &cli.IntFlag{ WebsocketPort = &cli.IntFlag{
Name: "websocket-port", Name: "websocket-port",
@ -34,6 +37,7 @@ var (
Value: 60001, Value: 60001,
Usage: "Libp2p TCP listening port for websocket connection (0 for random)", Usage: "Libp2p TCP listening port for websocket connection (0 for random)",
Destination: &options.Websocket.WSPort, Destination: &options.Websocket.WSPort,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_PORT"},
} }
WebsocketSecurePort = &cli.IntFlag{ WebsocketSecurePort = &cli.IntFlag{
Name: "websocket-secure-port", Name: "websocket-secure-port",
@ -41,6 +45,7 @@ var (
Value: 6443, Value: 6443,
Usage: "Libp2p TCP listening port for secure websocket connection (0 for random, binding to 443 requires root access)", Usage: "Libp2p TCP listening port for secure websocket connection (0 for random, binding to 443 requires root access)",
Destination: &options.Websocket.WSSPort, Destination: &options.Websocket.WSSPort,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_SECURE_PORT"},
} }
WebsocketAddress = &cli.StringFlag{ WebsocketAddress = &cli.StringFlag{
Name: "websocket-address", Name: "websocket-address",
@ -48,12 +53,14 @@ var (
Value: "0.0.0.0", Value: "0.0.0.0",
Usage: "Listening address for websocket connections", Usage: "Listening address for websocket connections",
Destination: &options.Websocket.Address, Destination: &options.Websocket.Address,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_ADDRESS"},
} }
WebsocketSecureSupport = &cli.BoolFlag{ WebsocketSecureSupport = &cli.BoolFlag{
Name: "websocket-secure-support", Name: "websocket-secure-support",
Aliases: []string{"wss"}, Aliases: []string{"wss"},
Usage: "Enable secure websockets support", Usage: "Enable secure websockets support",
Destination: &options.Websocket.Secure, Destination: &options.Websocket.Secure,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_SECURE_SUPPORT"},
} }
WebsocketSecureKeyPath = &cli.PathFlag{ WebsocketSecureKeyPath = &cli.PathFlag{
Name: "websocket-secure-key-path", Name: "websocket-secure-key-path",
@ -61,6 +68,7 @@ var (
Value: "/path/to/key.txt", Value: "/path/to/key.txt",
Usage: "Secure websocket key path", Usage: "Secure websocket key path",
Destination: &options.Websocket.KeyPath, Destination: &options.Websocket.KeyPath,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_SECURE_KEY_PATH"},
} }
WebsocketSecureCertPath = &cli.PathFlag{ WebsocketSecureCertPath = &cli.PathFlag{
Name: "websocket-secure-cert-path", Name: "websocket-secure-cert-path",
@ -68,12 +76,14 @@ var (
Value: "/path/to/cert.txt", Value: "/path/to/cert.txt",
Usage: "Secure websocket certificate path", Usage: "Secure websocket certificate path",
Destination: &options.Websocket.CertPath, Destination: &options.Websocket.CertPath,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_SECURE_CERT_PATH"},
} }
Dns4DomainName = &cli.StringFlag{ Dns4DomainName = &cli.StringFlag{
Name: "dns4-domain-name", Name: "dns4-domain-name",
Value: "", Value: "",
Usage: "The domain name resolving to the node's public IPv4 address", Usage: "The domain name resolving to the node's public IPv4 address",
Destination: &options.Dns4DomainName, Destination: &options.Dns4DomainName,
EnvVars: []string{"WAKUNODE2_WEBSOCKET_DNS4_DOMAIN_NAME"},
} }
NodeKey = &cli.GenericFlag{ NodeKey = &cli.GenericFlag{
Name: "nodekey", Name: "nodekey",
@ -81,19 +91,21 @@ var (
Value: &cliutils.PrivateKeyValue{ Value: &cliutils.PrivateKeyValue{
Value: &options.NodeKey, Value: &options.NodeKey,
}, },
EnvVars: []string{"GOWAKU-NODEKEY"}, EnvVars: []string{"WAKUNODE2_NODEKEY"},
} }
KeyFile = &cli.PathFlag{ KeyFile = &cli.PathFlag{
Name: "key-file", Name: "key-file",
Value: "./nodekey", Value: "./nodekey",
Usage: "Path to a file containing the private key for the P2P node", Usage: "Path to a file containing the private key for the P2P node",
Destination: &options.KeyFile, Destination: &options.KeyFile,
EnvVars: []string{"WAKUNODE2_KEY_FILE"},
} }
KeyPassword = &cli.StringFlag{ KeyPassword = &cli.StringFlag{
Name: "key-password", Name: "key-password",
Value: "secret", Value: "secret",
Usage: "Password used for the private key file", Usage: "Password used for the private key file",
Destination: &options.KeyPasswd, Destination: &options.KeyPasswd,
EnvVars: []string{"WAKUNODE2_KEY_PASSWORD"},
} }
GenerateKey = &cli.BoolFlag{ GenerateKey = &cli.BoolFlag{
Name: "generate-key", Name: "generate-key",
@ -111,29 +123,34 @@ var (
Value: &cliutils.MultiaddrSlice{ Value: &cliutils.MultiaddrSlice{
Values: &options.StaticNodes, Values: &options.StaticNodes,
}, },
EnvVars: []string{"WAKUNODE2_STATICNODE"},
} }
KeepAlive = &cli.DurationFlag{ KeepAlive = &cli.DurationFlag{
Name: "keep-alive", Name: "keep-alive",
Value: 5 * time.Minute, Value: 5 * time.Minute,
Usage: "Interval of time for pinging peers to keep the connection alive.", Usage: "Interval of time for pinging peers to keep the connection alive.",
Destination: &options.KeepAlive, Destination: &options.KeepAlive,
EnvVars: []string{"WAKUNODE2_KEEP_ALIVE"},
} }
PersistPeers = &cli.BoolFlag{ PersistPeers = &cli.BoolFlag{
Name: "persist-peers", Name: "persist-peers",
Usage: "Enable peer persistence", Usage: "Enable peer persistence",
Destination: &options.PersistPeers, Destination: &options.PersistPeers,
Value: false, Value: false,
EnvVars: []string{"WAKUNODE2_PERSIST_PEERS"},
} }
NAT = &cli.StringFlag{ NAT = &cli.StringFlag{
Name: "nat", // This was added so js-waku test don't fail Name: "nat", // This was added so js-waku test don't fail
Usage: "TODO: Not implemented yet. Specify method to use for determining public address: any, none ('any' will attempt upnp/pmp)", Usage: "TODO: Not implemented yet. Specify method to use for determining public address: any, none ('any' will attempt upnp/pmp)",
Value: "any", Value: "any",
Destination: &options.NAT, // TODO: accept none,any,upnp,extaddr Destination: &options.NAT, // TODO: accept none,any,upnp,extaddr
EnvVars: []string{"WAKUNODE2_NAT"},
} }
AdvertiseAddress = &cli.StringFlag{ AdvertiseAddress = &cli.StringFlag{
Name: "advertise-address", Name: "advertise-address",
Usage: "External address to advertise to other nodes (overrides --address and --ws-address flags)", Usage: "External address to advertise to other nodes (overrides --address and --ws-address flags)",
Destination: &options.AdvertiseAddress, Destination: &options.AdvertiseAddress,
EnvVars: []string{"WAKUNODE2_ADVERTISE_ADDRESS"},
} }
ShowAddresses = &cli.BoolFlag{ ShowAddresses = &cli.BoolFlag{
Name: "show-addresses", Name: "show-addresses",
@ -147,7 +164,8 @@ var (
Choices: []string{"DEBUG", "INFO", "WARN", "ERROR", "DPANIC", "PANIC", "FATAL"}, Choices: []string{"DEBUG", "INFO", "WARN", "ERROR", "DPANIC", "PANIC", "FATAL"},
Value: &options.LogLevel, Value: &options.LogLevel,
}, },
Usage: "Define the logging level (allowed values: DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL)", Usage: "Define the logging level (allowed values: DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL)",
EnvVars: []string{"WAKUNODE2_LOG_LEVEL"},
} }
LogEncoding = &cli.GenericFlag{ LogEncoding = &cli.GenericFlag{
Name: "log-encoding", Name: "log-encoding",
@ -156,41 +174,48 @@ var (
Choices: []string{"console", "nocolor", "json"}, Choices: []string{"console", "nocolor", "json"},
Value: &options.LogEncoding, Value: &options.LogEncoding,
}, },
EnvVars: []string{"WAKUNODE2_LOG_ENCODING"},
} }
LogOutput = &cli.StringFlag{ LogOutput = &cli.StringFlag{
Name: "log-output", Name: "log-output",
Value: "stdout", Value: "stdout",
Usage: "specifies where logging output should be written (stdout, file, file:./filename.log)", Usage: "specifies where logging output should be written (stdout, file, file:./filename.log)",
Destination: &options.LogOutput, Destination: &options.LogOutput,
EnvVars: []string{"WAKUNODE2_LOG_OUTPUT"},
} }
AgentString = &cli.StringFlag{ AgentString = &cli.StringFlag{
Name: "agent-string", Name: "agent-string",
Value: "go-waku", Value: "go-waku",
Usage: "client id to advertise", Usage: "client id to advertise",
Destination: &options.UserAgent, Destination: &options.UserAgent,
EnvVars: []string{"WAKUNODE2_AGENT_STRING"},
} }
Relay = &cli.BoolFlag{ Relay = &cli.BoolFlag{
Name: "relay", Name: "relay",
Value: true, Value: true,
Usage: "Enable relay protocol", Usage: "Enable relay protocol",
Destination: &options.Relay.Enable, Destination: &options.Relay.Enable,
EnvVars: []string{"WAKUNODE2_RELAY"},
} }
Topics = &cli.StringSliceFlag{ Topics = &cli.StringSliceFlag{
Name: "topics", Name: "topics",
Usage: "List of topics to listen", Usage: "List of topics to listen",
Destination: &options.Relay.Topics, Destination: &options.Relay.Topics,
EnvVars: []string{"WAKUNODE2_TOPICS"},
} }
RelayPeerExchange = &cli.BoolFlag{ RelayPeerExchange = &cli.BoolFlag{
Name: "relay-peer-exchange", Name: "relay-peer-exchange",
Value: false, Value: false,
Usage: "Enable GossipSub Peer Exchange", Usage: "Enable GossipSub Peer Exchange",
Destination: &options.Relay.PeerExchange, Destination: &options.Relay.PeerExchange,
EnvVars: []string{"WAKUNODE2_RELAY_PEER_EXCHANGE"},
} }
MinRelayPeersToPublish = &cli.IntFlag{ MinRelayPeersToPublish = &cli.IntFlag{
Name: "min-relay-peers-to-publish", Name: "min-relay-peers-to-publish",
Value: 1, Value: 1,
Usage: "Minimum number of peers to publish to Relay", Usage: "Minimum number of peers to publish to Relay",
Destination: &options.Relay.MinRelayPeersToPublish, Destination: &options.Relay.MinRelayPeersToPublish,
EnvVars: []string{"WAKUNODE2_MIN_RELAY_PEERS_TO_PUBLISH"},
} }
StoreNodeFlag = &cli.GenericFlag{ StoreNodeFlag = &cli.GenericFlag{
Name: "storenode", Name: "storenode",
@ -198,29 +223,34 @@ var (
Value: &cliutils.MultiaddrSlice{ Value: &cliutils.MultiaddrSlice{
Values: &options.Store.Nodes, Values: &options.Store.Nodes,
}, },
EnvVars: []string{"WAKUNODE2_STORENODE"},
} }
StoreFlag = &cli.BoolFlag{ StoreFlag = &cli.BoolFlag{
Name: "store", Name: "store",
Usage: "Enable store protocol to persist messages", Usage: "Enable store protocol to persist messages",
Destination: &options.Store.Enable, Destination: &options.Store.Enable,
EnvVars: []string{"WAKUNODE2_STORE"},
} }
StoreMessageRetentionTime = &cli.DurationFlag{ StoreMessageRetentionTime = &cli.DurationFlag{
Name: "store-message-retention-time", Name: "store-message-retention-time",
Value: time.Hour * 24 * 2, Value: time.Hour * 24 * 2,
Usage: "maximum number of seconds before a message is removed from the store. Set to 0 to disable it", Usage: "maximum number of seconds before a message is removed from the store. Set to 0 to disable it",
Destination: &options.Store.RetentionTime, Destination: &options.Store.RetentionTime,
EnvVars: []string{"WAKUNODE2_STORE_MESSAGE_RETENTION_TIME"},
} }
StoreMessageRetentionCapacity = &cli.IntFlag{ StoreMessageRetentionCapacity = &cli.IntFlag{
Name: "store-message-retention-capacity", Name: "store-message-retention-capacity",
Value: 0, Value: 0,
Usage: "maximum number of messages to store. Set to 0 to disable it", Usage: "maximum number of messages to store. Set to 0 to disable it",
Destination: &options.Store.RetentionMaxMessages, Destination: &options.Store.RetentionMaxMessages,
EnvVars: []string{"WAKUNODE2_STORE_MESSAGE_RETENTION_CAPACITY"},
} }
StoreMessageDBURL = &cli.StringFlag{ StoreMessageDBURL = &cli.StringFlag{
Name: "store-message-db-url", Name: "store-message-db-url",
Usage: "The database connection URL for persistent storage.", Usage: "The database connection URL for persistent storage.",
Value: "sqlite3://store.db", Value: "sqlite3://store.db",
Destination: &options.Store.DatabaseURL, Destination: &options.Store.DatabaseURL,
EnvVars: []string{"WAKUNODE2_STORE_MESSAGE_DB_URL"},
} }
StoreResumePeer = &cli.GenericFlag{ StoreResumePeer = &cli.GenericFlag{
Name: "store-resume-peer", Name: "store-resume-peer",
@ -228,40 +258,47 @@ var (
Value: &cliutils.MultiaddrSlice{ Value: &cliutils.MultiaddrSlice{
Values: &options.Store.ResumeNodes, Values: &options.Store.ResumeNodes,
}, },
EnvVars: []string{"WAKUNODE2_STORE_RESUME_PEER"},
} }
SwapFlag = &cli.BoolFlag{ SwapFlag = &cli.BoolFlag{
Name: "swap", Name: "swap",
Usage: "Enable swap protocol", Usage: "Enable swap protocol",
Value: false, Value: false,
Destination: &options.Swap.Enable, Destination: &options.Swap.Enable,
EnvVars: []string{"WAKUNODE2_SWAP"},
} }
SwapMode = &cli.IntFlag{ SwapMode = &cli.IntFlag{
Name: "swap-mode", Name: "swap-mode",
Value: 0, Value: 0,
Usage: "Swap mode: 0=soft, 1=mock, 2=hard", Usage: "Swap mode: 0=soft, 1=mock, 2=hard",
Destination: &options.Swap.Mode, Destination: &options.Swap.Mode,
EnvVars: []string{"WAKUNODE2_SWAP_MODE"},
} }
SwapPaymentThreshold = &cli.IntFlag{ SwapPaymentThreshold = &cli.IntFlag{
Name: "swap-payment-threshold", Name: "swap-payment-threshold",
Value: 100, Value: 100,
Usage: "Threshold for payment", Usage: "Threshold for payment",
Destination: &options.Swap.PaymentThreshold, Destination: &options.Swap.PaymentThreshold,
EnvVars: []string{"WAKUNODE2_SWAP_PAYMENT_THRESHOLD"},
} }
SwapDisconnectThreshold = &cli.IntFlag{ SwapDisconnectThreshold = &cli.IntFlag{
Name: "swap-disconnect-threshold", Name: "swap-disconnect-threshold",
Value: -100, Value: -100,
Usage: "Threshold for disconnecting", Usage: "Threshold for disconnecting",
Destination: &options.Swap.DisconnectThreshold, Destination: &options.Swap.DisconnectThreshold,
EnvVars: []string{"WAKUNODE2_SWAP_DISCONNECT_THRESHOLD"},
} }
FilterFlag = &cli.BoolFlag{ FilterFlag = &cli.BoolFlag{
Name: "filter", Name: "filter",
Usage: "Enable filter protocol", Usage: "Enable filter protocol",
Destination: &options.Filter.Enable, Destination: &options.Filter.Enable,
EnvVars: []string{"WAKUNODE2_FILTER"},
} }
LightClient = &cli.BoolFlag{ LightClient = &cli.BoolFlag{
Name: "light-client", Name: "light-client",
Usage: "Don't accept filter subscribers", Usage: "Don't accept filter subscribers",
Destination: &options.Filter.DisableFullNode, Destination: &options.Filter.DisableFullNode,
EnvVars: []string{"WAKUNODE2_LIGHT_CLIENT"},
} }
FilterNode = &cli.GenericFlag{ FilterNode = &cli.GenericFlag{
Name: "filternode", Name: "filternode",
@ -269,17 +306,20 @@ var (
Value: &cliutils.MultiaddrSlice{ Value: &cliutils.MultiaddrSlice{
Values: &options.Filter.Nodes, Values: &options.Filter.Nodes,
}, },
EnvVars: []string{"WAKUNODE2_FILTERNODE"},
} }
FilterTimeout = &cli.DurationFlag{ FilterTimeout = &cli.DurationFlag{
Name: "filter-timeout", Name: "filter-timeout",
Value: 14400 * time.Second, Value: 14400 * time.Second,
Usage: "Timeout for filter node in seconds", Usage: "Timeout for filter node in seconds",
Destination: &options.Filter.Timeout, Destination: &options.Filter.Timeout,
EnvVars: []string{"WAKUNODE2_FILTER_TIMEOUT"},
} }
LightPush = &cli.BoolFlag{ LightPush = &cli.BoolFlag{
Name: "lightpush", Name: "lightpush",
Usage: "Enable lightpush protocol", Usage: "Enable lightpush protocol",
Destination: &options.LightPush.Enable, Destination: &options.LightPush.Enable,
EnvVars: []string{"WAKUNODE2_LIGHTPUSH"},
} }
LightPushNode = &cli.GenericFlag{ LightPushNode = &cli.GenericFlag{
Name: "lightpushnode", Name: "lightpushnode",
@ -287,32 +327,38 @@ var (
Value: &cliutils.MultiaddrSlice{ Value: &cliutils.MultiaddrSlice{
Values: &options.LightPush.Nodes, Values: &options.LightPush.Nodes,
}, },
EnvVars: []string{"WAKUNODE2_LIGHTPUSHNODE"},
} }
Discv5Discovery = &cli.BoolFlag{ Discv5Discovery = &cli.BoolFlag{
Name: "discv5-discovery", Name: "discv5-discovery",
Usage: "Enable discovering nodes via Node Discovery v5", Usage: "Enable discovering nodes via Node Discovery v5",
Destination: &options.DiscV5.Enable, Destination: &options.DiscV5.Enable,
EnvVars: []string{"WAKUNODE2_DISCV5_DISCOVERY"},
} }
Discv5BootstrapNode = &cli.StringSliceFlag{ Discv5BootstrapNode = &cli.StringSliceFlag{
Name: "discv5-bootstrap-node", Name: "discv5-bootstrap-node",
Usage: "Text-encoded ENR for bootstrap node. Used when connecting to the network. Option may be repeated", Usage: "Text-encoded ENR for bootstrap node. Used when connecting to the network. Option may be repeated",
Destination: &options.DiscV5.Nodes, Destination: &options.DiscV5.Nodes,
EnvVars: []string{"WAKUNODE2_DISCV5_BOOTSTRAP_NODE"},
} }
Discv5UDPPort = &cli.IntFlag{ Discv5UDPPort = &cli.IntFlag{
Name: "discv5-udp-port", Name: "discv5-udp-port",
Value: 9000, Value: 9000,
Usage: "Listening UDP port for Node Discovery v5.", Usage: "Listening UDP port for Node Discovery v5.",
Destination: &options.DiscV5.Port, Destination: &options.DiscV5.Port,
EnvVars: []string{"WAKUNODE2_DISCV5_UDP_PORT"},
} }
Discv5ENRAutoUpdate = &cli.BoolFlag{ Discv5ENRAutoUpdate = &cli.BoolFlag{
Name: "discv5-enr-auto-update", Name: "discv5-enr-auto-update",
Usage: "Discovery can automatically update its ENR with the IP address as seen by other nodes it communicates with.", Usage: "Discovery can automatically update its ENR with the IP address as seen by other nodes it communicates with.",
Destination: &options.DiscV5.AutoUpdate, Destination: &options.DiscV5.AutoUpdate,
EnvVars: []string{"WAKUNODE2_DISCV5_ENR_AUTO_UPDATE"},
} }
PeerExchange = &cli.BoolFlag{ PeerExchange = &cli.BoolFlag{
Name: "peer-exchange", Name: "peer-exchange",
Usage: "Enable waku peer exchange protocol (responder side)", Usage: "Enable waku peer exchange protocol (responder side)",
Destination: &options.PeerExchange.Enable, Destination: &options.PeerExchange.Enable,
EnvVars: []string{"WAKUNODE2_PEER_EXCHANGE"},
} }
PeerExchangeNode = &cli.GenericFlag{ PeerExchangeNode = &cli.GenericFlag{
Name: "peer-exchange-node", Name: "peer-exchange-node",
@ -320,28 +366,33 @@ var (
Value: &cliutils.MultiaddrValue{ Value: &cliutils.MultiaddrValue{
Value: &options.PeerExchange.Node, Value: &options.PeerExchange.Node,
}, },
EnvVars: []string{"WAKUNODE2_PEER_EXCHANGE_NODE"},
} }
DNSDiscovery = &cli.BoolFlag{ DNSDiscovery = &cli.BoolFlag{
Name: "dns-discovery", Name: "dns-discovery",
Usage: "Enable DNS discovery", Usage: "Enable DNS discovery",
Destination: &options.DNSDiscovery.Enable, Destination: &options.DNSDiscovery.Enable,
EnvVars: []string{"WAKUNODE2_DNS_DISCOVERY"},
} }
DNSDiscoveryUrl = &cli.StringSliceFlag{ DNSDiscoveryUrl = &cli.StringSliceFlag{
Name: "dns-discovery-url", Name: "dns-discovery-url",
Usage: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'", Usage: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'",
Destination: &options.DNSDiscovery.URLs, Destination: &options.DNSDiscovery.URLs,
EnvVars: []string{"WAKUNODE2_DNS_DISCOVERY_URL"},
} }
DNSDiscoveryNameServer = &cli.StringFlag{ DNSDiscoveryNameServer = &cli.StringFlag{
Name: "dns-discovery-name-server", Name: "dns-discovery-name-server",
Aliases: []string{"dns-discovery-nameserver"}, Aliases: []string{"dns-discovery-nameserver"},
Usage: "DNS nameserver IP to query (empty to use system's default)", Usage: "DNS nameserver IP to query (empty to use system's default)",
Destination: &options.DNSDiscovery.Nameserver, Destination: &options.DNSDiscovery.Nameserver,
EnvVars: []string{"WAKUNODE2_DNS_DISCOVERY_NAME_SERVER"},
} }
MetricsServer = &cli.BoolFlag{ MetricsServer = &cli.BoolFlag{
Name: "metrics-server", Name: "metrics-server",
Aliases: []string{"metrics"}, Aliases: []string{"metrics"},
Usage: "Enable the metrics server", Usage: "Enable the metrics server",
Destination: &options.Metrics.Enable, Destination: &options.Metrics.Enable,
EnvVars: []string{"WAKUNODE2_METRICS_SERVER"},
} }
MetricsServerAddress = &cli.StringFlag{ MetricsServerAddress = &cli.StringFlag{
Name: "metrics-server-address", Name: "metrics-server-address",
@ -349,6 +400,7 @@ var (
Value: "127.0.0.1", Value: "127.0.0.1",
Usage: "Listening address of the metrics server", Usage: "Listening address of the metrics server",
Destination: &options.Metrics.Address, Destination: &options.Metrics.Address,
EnvVars: []string{"WAKUNODE2_METRICS_SERVER_ADDRESS"},
} }
MetricsServerPort = &cli.IntFlag{ MetricsServerPort = &cli.IntFlag{
Name: "metrics-server-port", Name: "metrics-server-port",
@ -356,80 +408,94 @@ var (
Value: 8008, Value: 8008,
Usage: "Listening HTTP port of the metrics server", Usage: "Listening HTTP port of the metrics server",
Destination: &options.Metrics.Port, Destination: &options.Metrics.Port,
EnvVars: []string{"WAKUNODE2_METRICS_SERVER_PORT"},
} }
RPCFlag = &cli.BoolFlag{ RPCFlag = &cli.BoolFlag{
Name: "rpc", Name: "rpc",
Usage: "Enable the rpc server", Usage: "Enable the rpc server",
Destination: &options.RPCServer.Enable, Destination: &options.RPCServer.Enable,
EnvVars: []string{"WAKUNODE2_RPC"},
} }
RPCPort = &cli.IntFlag{ RPCPort = &cli.IntFlag{
Name: "rpc-port", Name: "rpc-port",
Value: 8545, Value: 8545,
Usage: "Listening port of the rpc server", Usage: "Listening port of the rpc server",
Destination: &options.RPCServer.Port, Destination: &options.RPCServer.Port,
EnvVars: []string{"WAKUNODE2_RPC_PORT"},
} }
RPCAddress = &cli.StringFlag{ RPCAddress = &cli.StringFlag{
Name: "rpc-address", Name: "rpc-address",
Value: "127.0.0.1", Value: "127.0.0.1",
Usage: "Listening address of the rpc server", Usage: "Listening address of the rpc server",
Destination: &options.RPCServer.Address, Destination: &options.RPCServer.Address,
EnvVars: []string{"WAKUNODE2_RPC_ADDRESS"},
} }
RPCRelayCacheCapacity = &cli.IntFlag{ RPCRelayCacheCapacity = &cli.IntFlag{
Name: "rpc-relay-cache-capacity", Name: "rpc-relay-cache-capacity",
Value: 30, Value: 30,
Usage: "Capacity of the Relay REST API message cache", Usage: "Capacity of the Relay REST API message cache",
Destination: &options.RPCServer.RelayCacheCapacity, Destination: &options.RPCServer.RelayCacheCapacity,
EnvVars: []string{"WAKUNODE2_RPC_RELAY_CACHE_CAPACITY"},
} }
RPCAdmin = &cli.BoolFlag{ RPCAdmin = &cli.BoolFlag{
Name: "rpc-admin", Name: "rpc-admin",
Value: false, Value: false,
Usage: "Enable access to JSON-RPC Admin API", Usage: "Enable access to JSON-RPC Admin API",
Destination: &options.RPCServer.Admin, Destination: &options.RPCServer.Admin,
EnvVars: []string{"WAKUNODE2_RPC_ADMIN"},
} }
RPCPrivate = &cli.BoolFlag{ RPCPrivate = &cli.BoolFlag{
Name: "rpc-private", Name: "rpc-private",
Value: false, Value: false,
Usage: "Enable access to JSON-RPC Private API", Usage: "Enable access to JSON-RPC Private API",
Destination: &options.RPCServer.Private, Destination: &options.RPCServer.Private,
EnvVars: []string{"WAKUNODE2_RPC_PRIVATE"},
} }
RESTFlag = &cli.BoolFlag{ RESTFlag = &cli.BoolFlag{
Name: "rest", Name: "rest",
Usage: "Enable Waku REST HTTP server", Usage: "Enable Waku REST HTTP server",
Destination: &options.RESTServer.Enable, Destination: &options.RESTServer.Enable,
EnvVars: []string{"WAKUNODE2_REST"},
} }
RESTAddress = &cli.StringFlag{ RESTAddress = &cli.StringFlag{
Name: "rest-address", Name: "rest-address",
Value: "127.0.0.1", Value: "127.0.0.1",
Usage: "Listening address of the REST HTTP server", Usage: "Listening address of the REST HTTP server",
Destination: &options.RESTServer.Address, Destination: &options.RESTServer.Address,
EnvVars: []string{"WAKUNODE2_REST_ADDRESS"},
} }
RESTPort = &cli.IntFlag{ RESTPort = &cli.IntFlag{
Name: "rest-port", Name: "rest-port",
Value: 8645, Value: 8645,
Usage: "Listening port of the REST HTTP server", Usage: "Listening port of the REST HTTP server",
Destination: &options.RESTServer.Port, Destination: &options.RESTServer.Port,
EnvVars: []string{"WAKUNODE2_REST_PORT"},
} }
RESTRelayCacheCapacity = &cli.IntFlag{ RESTRelayCacheCapacity = &cli.IntFlag{
Name: "rest-relay-cache-capacity", Name: "rest-relay-cache-capacity",
Value: 30, Value: 30,
Usage: "Capacity of the Relay REST API message cache", Usage: "Capacity of the Relay REST API message cache",
Destination: &options.RESTServer.RelayCacheCapacity, Destination: &options.RESTServer.RelayCacheCapacity,
EnvVars: []string{"WAKUNODE2_REST_RELAY_CACHE_CAPACITY"},
} }
RESTAdmin = &cli.BoolFlag{ RESTAdmin = &cli.BoolFlag{
Name: "rest-admin", Name: "rest-admin",
Value: false, Value: false,
Usage: "Enable access to REST HTTP Admin API", Usage: "Enable access to REST HTTP Admin API",
Destination: &options.RESTServer.Admin, Destination: &options.RESTServer.Admin,
EnvVars: []string{"WAKUNODE2_REST_ADMIN"},
} }
RESTPrivate = &cli.BoolFlag{ RESTPrivate = &cli.BoolFlag{
Name: "rest-private", Name: "rest-private",
Value: false, Value: false,
Usage: "Enable access to REST HTTP Private API", Usage: "Enable access to REST HTTP Private API",
Destination: &options.RESTServer.Private, Destination: &options.RESTServer.Private,
EnvVars: []string{"WAKUNODE2_REST_PRIVATE"},
} }
PProf = &cli.BoolFlag{ PProf = &cli.BoolFlag{
Name: "pprof", Name: "pprof",
Usage: "provides runtime profiling data at /debug/pprof in both REST and RPC servers if they're enabled", Usage: "provides runtime profiling data at /debug/pprof in both REST and RPC servers if they're enabled",
Destination: &options.PProf, Destination: &options.PProf,
EnvVars: []string{"WAKUNODE2_PPROF"},
} }
) )

View File

@ -11,11 +11,14 @@ type MultiaddrSlice struct {
} }
func (k *MultiaddrSlice) Set(value string) error { func (k *MultiaddrSlice) Set(value string) error {
ma, err := multiaddr.NewMultiaddr(value) addresses := strings.Split(value, ",")
if err != nil { for _, addr := range addresses {
return err ma, err := multiaddr.NewMultiaddr(addr)
if err != nil {
return err
}
*k.Values = append(*k.Values, ma)
} }
*k.Values = append(*k.Values, ma)
return nil return nil
} }