diff --git a/api/defaults.go b/api/defaults.go index 6ad0bb82a..003c847dc 100644 --- a/api/defaults.go +++ b/api/defaults.go @@ -283,6 +283,10 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o nodeConfig.WakuV2Config.Nameserver = *request.WakuV2Nameserver } + if request.TelemetryServerURL != "" { + nodeConfig.WakuV2Config.TelemetryServerURL = request.TelemetryServerURL + } + nodeConfig.ShhextConfig = params.ShhextConfig{ BackupDisabledDataDir: request.BackupDisabledDataDir, InstallationID: installationID, diff --git a/cmd/status-cli/main.go b/cmd/status-cli/main.go index db3c8f592..66c1cd1ab 100644 --- a/cmd/status-cli/main.go +++ b/cmd/status-cli/main.go @@ -19,6 +19,7 @@ const NameFlag = "name" const AddFlag = "add" const PortFlag = "port" const APIModulesFlag = "api-modules" +const TelemetryServerURLFlag = "telemetry-server-url" const RetrieveInterval = 300 * time.Millisecond const SendInterval = 1 * time.Second @@ -36,6 +37,11 @@ var CommonFlags = []cli.Flag{ Value: "waku,wakuext,wakuv2,permissions,eth", Usage: "API modules to enable", }, + &cli.StringFlag{ + Name: TelemetryServerURLFlag, + Aliases: []string{"t"}, + Usage: "Telemetry server URL", + }, } var SimulateFlags = append([]cli.Flag{ diff --git a/cmd/status-cli/serve.go b/cmd/status-cli/serve.go index 9a75ca73b..75117303b 100644 --- a/cmd/status-cli/serve.go +++ b/cmd/status-cli/serve.go @@ -36,8 +36,9 @@ func serve(cCtx *cli.Context) error { name := cCtx.String(NameFlag) port := cCtx.Int(PortFlag) apiModules := cCtx.String(APIModulesFlag) + telemetryUrl := cCtx.String(TelemetryServerURLFlag) - cli, err := start(cCtx, name, port, apiModules) + cli, err := start(cCtx, name, port, apiModules, telemetryUrl) if err != nil { return err } diff --git a/cmd/status-cli/simulate.go b/cmd/status-cli/simulate.go index 65606977b..15aee6978 100644 --- a/cmd/status-cli/simulate.go +++ b/cmd/status-cli/simulate.go @@ -37,14 +37,15 @@ func simulate(cCtx *cli.Context) error { // Start messengers apiModules := cCtx.String(APIModulesFlag) + telemetryUrl := cCtx.String(TelemetryServerURLFlag) - alice, err := start(cCtx, "Alice", 0, apiModules) + alice, err := start(cCtx, "Alice", 0, apiModules, telemetryUrl) if err != nil { return err } defer alice.stop() - charlie, err := start(cCtx, "Charlie", 0, apiModules) + charlie, err := start(cCtx, "Charlie", 0, apiModules, telemetryUrl) if err != nil { return err } diff --git a/cmd/status-cli/util.go b/cmd/status-cli/util.go index 3e96fdf4a..30ceca0a5 100644 --- a/cmd/status-cli/util.go +++ b/cmd/status-cli/util.go @@ -34,7 +34,7 @@ func setupLogger(file string) *zap.Logger { return logutils.ZapLogger() } -func start(cCtx *cli.Context, name string, port int, apiModules string) (*StatusCLI, error) { +func start(cCtx *cli.Context, name string, port int, apiModules string, telemetryUrl string) (*StatusCLI, error) { namedLogger := logger.Named(name) namedLogger.Info("starting messager") @@ -60,6 +60,7 @@ func start(cCtx *cli.Context, name string, port int, apiModules string) (*Status HTTPHost: "127.0.0.1", HTTPPort: port, }, + TelemetryServerURL: telemetryUrl, } _, err = backend.CreateAccountAndLogin(createAccountRequest) if err != nil { diff --git a/node/status_node_services.go b/node/status_node_services.go index d55dcea6c..ddfe85a07 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -142,9 +142,11 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server if err != nil { return err } + if telemetryServerURL != "" { + config.WakuV2Config.TelemetryServerURL = telemetryServerURL + } } - - waku2Service, err := b.wakuV2Service(config, telemetryServerURL) + waku2Service, err := b.wakuV2Service(config) if err != nil { return err } @@ -312,7 +314,7 @@ func (b *StatusNode) wakuService(wakuCfg *params.WakuConfig, clusterCfg *params. } -func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServerURL string) (*wakuv2.Waku, error) { +func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig) (*wakuv2.Waku, error) { if b.wakuV2Srvc == nil { cfg := &wakuv2.Config{ MaxMessageSize: wakucommon.DefaultMaxMessageSize, @@ -332,7 +334,7 @@ func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServe AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate, DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(), UseShardAsDefaultTopic: nodeConfig.WakuV2Config.UseShardAsDefaultTopic, - TelemetryServerURL: telemetryServerURL, + TelemetryServerURL: nodeConfig.WakuV2Config.TelemetryServerURL, ClusterID: nodeConfig.ClusterConfig.ClusterID, } diff --git a/params/config.go b/params/config.go index 37c84d73e..6b847dc4b 100644 --- a/params/config.go +++ b/params/config.go @@ -214,6 +214,8 @@ type WakuV2Config struct { // StoreSeconds indicates the maximum number of seconds before a message is removed from the store StoreSeconds int + TelemetryServerURL string + // UseShardAsDefaultTopic indicates whether the default shard should be used instead of the default relay topic UseShardAsDefaultTopic bool } diff --git a/protocol/requests/create_account.go b/protocol/requests/create_account.go index 42d67949d..b24b8a3b5 100644 --- a/protocol/requests/create_account.go +++ b/protocol/requests/create_account.go @@ -66,6 +66,8 @@ type CreateAccount struct { TorrentConfigEnabled *bool TorrentConfigPort *int + TelemetryServerURL string `json:"telemetryServerURL"` + APIConfig *APIConfig `json:"apiConfig"` }