2022-11-26 11:57:11 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2023-01-11 11:58:49 -04:00
|
|
|
cli "github.com/urfave/cli/v2"
|
|
|
|
"github.com/urfave/cli/v2/altsrc"
|
2023-08-09 14:14:54 -04:00
|
|
|
"github.com/waku-org/go-waku/cmd/waku/keygen"
|
2023-08-18 17:24:04 -04:00
|
|
|
"github.com/waku-org/go-waku/cmd/waku/rlngenerate"
|
2022-11-26 11:57:11 -04:00
|
|
|
"github.com/waku-org/go-waku/waku/v2/node"
|
2023-10-18 15:21:37 -04:00
|
|
|
"github.com/waku-org/go-waku/waku/v2/utils"
|
|
|
|
"go.uber.org/zap"
|
2022-11-26 11:57:11 -04:00
|
|
|
)
|
|
|
|
|
2023-08-09 14:14:54 -04:00
|
|
|
var options NodeOptions
|
2022-11-26 11:57:11 -04:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
// Defaults
|
|
|
|
options.LogLevel = "INFO"
|
|
|
|
options.LogEncoding = "console"
|
|
|
|
|
|
|
|
cliFlags := []cli.Flag{
|
2023-01-11 11:58:49 -04:00
|
|
|
&cli.StringFlag{Name: "config-file", Usage: "loads configuration from a TOML file (cmd-line parameters take precedence)"},
|
2022-12-06 22:44:05 +05:30
|
|
|
TcpPort,
|
|
|
|
Address,
|
2023-08-03 21:51:15 +05:30
|
|
|
MaxPeerConnections,
|
2023-09-27 12:16:37 +05:30
|
|
|
PeerStoreCapacity,
|
2022-12-06 22:44:05 +05:30
|
|
|
WebsocketSupport,
|
|
|
|
WebsocketPort,
|
|
|
|
WebsocketSecurePort,
|
|
|
|
WebsocketAddress,
|
|
|
|
WebsocketSecureSupport,
|
|
|
|
WebsocketSecureKeyPath,
|
|
|
|
WebsocketSecureCertPath,
|
2023-07-06 17:40:57 -04:00
|
|
|
DNS4DomainName,
|
2022-12-06 22:44:05 +05:30
|
|
|
NodeKey,
|
|
|
|
KeyFile,
|
|
|
|
KeyPassword,
|
2023-10-15 15:16:40 -04:00
|
|
|
ClusterID,
|
2022-12-06 22:44:05 +05:30
|
|
|
StaticNode,
|
|
|
|
KeepAlive,
|
|
|
|
PersistPeers,
|
|
|
|
NAT,
|
2023-05-08 11:19:44 -04:00
|
|
|
IPAddress,
|
|
|
|
ExtMultiaddresses,
|
2022-12-06 22:44:05 +05:30
|
|
|
ShowAddresses,
|
2023-05-12 17:52:42 -04:00
|
|
|
CircuitRelay,
|
2023-09-28 16:08:40 -04:00
|
|
|
ForceReachability,
|
2023-05-24 11:34:35 -04:00
|
|
|
ResourceScalingMemoryPercent,
|
|
|
|
ResourceScalingFDPercent,
|
2024-01-08 15:05:21 -04:00
|
|
|
IPColocationLimit,
|
2022-12-06 22:44:05 +05:30
|
|
|
LogLevel,
|
|
|
|
LogEncoding,
|
|
|
|
LogOutput,
|
|
|
|
AgentString,
|
|
|
|
Relay,
|
|
|
|
Topics,
|
2023-09-06 10:07:21 +05:30
|
|
|
ContentTopics,
|
|
|
|
PubSubTopics,
|
2023-05-02 11:10:45 -04:00
|
|
|
ProtectedTopics,
|
2022-12-06 22:44:05 +05:30
|
|
|
RelayPeerExchange,
|
|
|
|
MinRelayPeersToPublish,
|
2024-01-03 07:06:41 +05:30
|
|
|
MaxRelayMsgSize,
|
2022-12-06 22:44:05 +05:30
|
|
|
StoreNodeFlag,
|
|
|
|
StoreFlag,
|
2022-12-09 15:26:24 -04:00
|
|
|
StoreMessageDBURL,
|
2022-12-06 22:44:05 +05:30
|
|
|
StoreMessageRetentionTime,
|
|
|
|
StoreMessageRetentionCapacity,
|
2023-08-08 11:46:32 -04:00
|
|
|
StoreMessageDBMigration,
|
2022-12-06 22:44:05 +05:30
|
|
|
FilterFlag,
|
|
|
|
FilterNode,
|
|
|
|
FilterTimeout,
|
2023-04-26 09:42:17 -04:00
|
|
|
FilterLegacyFlag,
|
|
|
|
FilterLegacyNode,
|
|
|
|
FilterLegacyLightClient,
|
2022-12-06 22:44:05 +05:30
|
|
|
LightPush,
|
|
|
|
LightPushNode,
|
|
|
|
Discv5Discovery,
|
|
|
|
Discv5BootstrapNode,
|
|
|
|
Discv5UDPPort,
|
|
|
|
Discv5ENRAutoUpdate,
|
|
|
|
PeerExchange,
|
|
|
|
PeerExchangeNode,
|
|
|
|
DNSDiscovery,
|
|
|
|
DNSDiscoveryUrl,
|
|
|
|
DNSDiscoveryNameServer,
|
2023-03-09 11:48:25 -04:00
|
|
|
Rendezvous,
|
|
|
|
RendezvousNode,
|
2023-03-09 18:42:50 -04:00
|
|
|
RendezvousServer,
|
2022-12-06 22:44:05 +05:30
|
|
|
MetricsServer,
|
|
|
|
MetricsServerAddress,
|
|
|
|
MetricsServerPort,
|
|
|
|
RPCFlag,
|
|
|
|
RPCPort,
|
|
|
|
RPCAddress,
|
|
|
|
RPCRelayCacheCapacity,
|
|
|
|
RPCAdmin,
|
|
|
|
RESTFlag,
|
|
|
|
RESTAddress,
|
|
|
|
RESTPort,
|
|
|
|
RESTRelayCacheCapacity,
|
2023-11-04 14:24:20 +07:00
|
|
|
RESTFilterCacheCapacity,
|
2022-12-06 22:44:05 +05:30
|
|
|
RESTAdmin,
|
2022-12-10 20:08:25 -04:00
|
|
|
PProf,
|
2022-11-26 11:57:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
rlnFlags := rlnFlags()
|
|
|
|
cliFlags = append(cliFlags, rlnFlags...)
|
|
|
|
|
|
|
|
cli.VersionFlag = &cli.BoolFlag{
|
|
|
|
Name: "version",
|
|
|
|
Usage: "prints the version",
|
|
|
|
}
|
|
|
|
|
|
|
|
app := &cli.App{
|
|
|
|
Name: "gowaku",
|
|
|
|
Version: node.GetVersionInfo().String(),
|
2023-01-11 11:58:49 -04:00
|
|
|
Before: altsrc.InitInputSourceWithContext(cliFlags, altsrc.NewTomlSourceFromFlagFunc("config-file")),
|
2022-11-26 11:57:11 -04:00
|
|
|
Flags: cliFlags,
|
|
|
|
Action: func(c *cli.Context) error {
|
2023-10-18 15:21:37 -04:00
|
|
|
err := Execute(options)
|
|
|
|
if err != nil {
|
|
|
|
utils.Logger().Error("failure while executing wakunode", zap.Error(err))
|
|
|
|
switch e := err.(type) {
|
|
|
|
case cli.ExitCoder:
|
|
|
|
return e
|
|
|
|
case error:
|
|
|
|
return cli.Exit(err.Error(), 1)
|
|
|
|
}
|
|
|
|
}
|
2022-11-26 11:57:11 -04:00
|
|
|
return nil
|
|
|
|
},
|
2023-08-09 14:14:54 -04:00
|
|
|
Commands: []*cli.Command{
|
|
|
|
&keygen.Command,
|
2023-08-18 17:24:04 -04:00
|
|
|
&rlngenerate.Command,
|
2023-08-09 14:14:54 -04:00
|
|
|
},
|
2022-11-26 11:57:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
err := app.Run(os.Args)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|