From a9e1945e6fe761e14f4a5a35c08658d7f353c592 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:44:44 -0500 Subject: [PATCH] update services-config.json & dmsghttp-config.json (#1874) * update services-config.json * update dmsghttp-config.json * validate services-config.json --- cmd/skywire/commands/root.go | 99 +++++++++++++++++++++ dmsghttp-config.json | 8 +- services-config.json | 168 ++++++++++++++++------------------- 3 files changed, 181 insertions(+), 94 deletions(-) diff --git a/cmd/skywire/commands/root.go b/cmd/skywire/commands/root.go index a63d30c5e..5124388d0 100644 --- a/cmd/skywire/commands/root.go +++ b/cmd/skywire/commands/root.go @@ -99,6 +99,7 @@ var treeCmd = &cobra.Command{ Use: "tree", Short: "subcommand tree", Long: `subcommand tree`, + Hidden: true, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -159,6 +160,7 @@ var docCmd = &cobra.Command{ generate toc: cat cmd/skywire/README1.md | gh-md-toc`, + Hidden: true, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -254,6 +256,103 @@ var docCmd = &cobra.Command{ }, } +/* +cfgCmd.Flags().StringVarP(&pdmsgdURL, "dprod", "q", skywire.Prod.DmsgDiscovery, "prod dmsg discovery url") +cfgCmd.Flags().StringVarP(&tdmsgdURL, "dtest", "r", skywire.Test.DmsgDiscovery, "test dmsg discovery url") +cfgCmd.Flags().StringVarP(&dmsghttpCfg, "dfile", "u", "dmsghttp-config.json", "dmsghttp config json file") +cfgCmd.Flags().BoolVarP(&writeDmsghttp, "dw", "x", false, "write updates to dmsghttp config file") +*/ + +/* +var ( +prodURL,testURL,svcCfg,pdmsgdURL,tdmsgdURL,dmsghttpCfg string +writeSvc, writeDmsghttp bool +) + +// CombinedConfig represents the combined configuration of the production services +type CombinedConfig struct { + Prod struct { + Conf string `json:"conf,omitempty"` + skywire.Services `json:",inline"` // Embed the Services struct + } `json:"prod"` +} + +func init() { + cfgCmd.Flags().StringVarP(&prodURL, "prod", "p", skywire.ProdConf.Conf, "prod configuration url") + cfgCmd.Flags().StringVarP(&svcCfg, "sfile", "s", "services-config.json", "services config json file") + cfgCmd.Flags().BoolVarP(&writeSvc, "sw", "w", false, "write updates to services config file") + cfgCmd.Flags().StringVarP(&testURL, "test", "t", skywire.TestConf.Conf, "test configuration url") +} + +var cfgCmd = &cobra.Command{ + Use: "cfg", + Short: "update services-config.json & dmsghttp-config.json", + Long: `update services-config.json & dmsghttp-config.json`, + Hidden: true, + SilenceErrors: true, + SilenceUsage: true, + DisableSuggestions: true, + DisableFlagsInUseLine: true, + Run: func(_ *cobra.Command, _ []string) { + _, _ = script.File(svcCfg).JQ(".prod").Stdout() + os.Exit(0) +// pConf, err := script.File(svcCfg).JQ(".prod").Bytes() +// tConf, err := script.File(svcCfg).JQ(".test").Bytes() + // Fetch the prod configuration from prodURL + if prodURL != "" { + prodConf, err := script.Get(prodURL).JQ(".").Bytes() + if err != nil { + log.Fatal(err) + } + + // Create an instance of the CombinedConfig struct + var combinedConfig CombinedConfig + combinedConfig.Prod.Conf = skywire.ProdConf.Conf // Assign the existing Conf + + // Unmarshal the fetched prod configuration into the Services field + err = json.Unmarshal(prodConf, &combinedConfig.Prod.Services) + if err != nil { + log.Fatalf("Error unmarshaling prod config into Services: %v", err) + } + + // Read the existing services-config.json file + existingConfigData, err := os.ReadFile(svcCfg) + if err != nil { + log.Fatalf("Error reading services config file: %v", err) + } + + // Parse the existing configuration + var existingConfig map[string]interface{} + err = json.Unmarshal(existingConfigData, &existingConfig) + if err != nil { + log.Fatalf("Error unmarshaling existing services config: %v", err) + } + + // Update the prod section with the new configuration + existingConfig["prod"] = combinedConfig.Prod + + // Marshal the updated configuration back to JSON for output or saving + marshaled, err := json.MarshalIndent(existingConfig, "", " ") + if err != nil { + log.Fatalf("Error marshaling updated config: %v", err) + } + + // Print the updated configuration to the console + fmt.Println(string(marshaled)) + + // Write to file if the writeSvc flag is set + if writeSvc { + _, err := script.Echo(string(marshaled)).WriteFile(svcCfg) + if err != nil { + log.Fatalf("Error writing to services config file: %v", err) + } + fmt.Printf("Updated %s successfully.\n",svcCfg) + } + } + }, +} +*/ + // Execute executes root CLI command. func Execute() { if err := RootCmd.Execute(); err != nil { diff --git a/dmsghttp-config.json b/dmsghttp-config.json index 7afb309b8..58e746297 100644 --- a/dmsghttp-config.json +++ b/dmsghttp-config.json @@ -54,15 +54,15 @@ } }, { - "static": "03d5b55d1133b26485c664cf8b95cff6746d1e321c34e48c9fed293eff0d6d49e5", + "static": "03717576ada5b1744e395c66c2bb11cea73b0e23d0dcd54422139b1a7f12e962c4", "server": { - "address": "170.187.228.44:30083" + "address": "139.162.173.101:30083" } }, { - "static": "0228af3fd99c8d86a882495c8e0202bdd4da78c69e013065d8634286dd4a0ac098", + "static": "02a2d4c346dabd165fd555dfdba4a7f4d18786fe7e055e562397cd5102bdd7f8dd", "server": { - "address": "170.187.228.178:30084" + "address": "139.162.173.101:30082" } } ], diff --git a/services-config.json b/services-config.json index 7dea11228..91fafab04 100644 --- a/services-config.json +++ b/services-config.json @@ -1,92 +1,80 @@ { - "test": { - "conf": "http://conf.skywire.dev", - "dmsg_discovery": "http://dmsgd.skywire.dev", - "transport_discovery": "http://tpd.skywire.dev", - "address_resolver": "http://ar.skywire.dev", - "route_finder": "http://rf.skywire.dev", - "route_setup_nodes": [ - "026c2a3e92d6253c5abd71a42628db6fca9dd9aa037ab6f4e3a31108558dfd87cf" - ], - "transport_setup": [ - "03530b786c670fc7f5ab9021478c7ec9cd06a03f3ea1416c50c4a8889ef5bba80e", - "03271c0de223b80400d9bd4b7722b536a245eb6c9c3176781ee41e7bac8f9bad21", - "03a792e6d960c88c6fb2184ee4f16714c58b55f0746840617a19f7dd6e021699d9", - "0313efedc579f57f05d4f5bc3fbf0261f31e51cdcfde7e568169acf92c78868926", - "025c7bbf23e3441a36d7e8a1e9d717921e2a49a2ce035680fec4808a048d244c8a", - "030eb6967f6e23e81db0d214f925fc5ce3371e1b059fb8379ae3eb1edfc95e0b46", - "02e582c0a5e5563aad47f561b272e4c3a9f7ac716258b58e58eb50afd83c286a7f", - "02ddc6c749d6ed067bb68df19c9bcb1a58b7587464043b1707398ffa26a9746b26", - "03aa0b1c4e23616872058c11c6efba777c130a85eaf909945d697399a1eb08426d", - "03adb2c924987d8deef04d02bd95236c5ae172fe5dfe7273e0461d96bf4bc220be" - ], - "uptime_tracker": "http://ut.skywire.dev", - "service_discovery": "http://sd.skywire.dev", - "stun_servers": [ - "139.162.12.30:3478", - "170.187.228.181:3478", - "172.104.161.184:3478", - "170.187.231.137:3478", - "143.42.74.91:3478", - "170.187.225.78:3478", - "143.42.78.123:3478", - "139.162.12.244:3478" - ], - "dns_server": "1.1.1.1", - "survey_whitelist": [ - "02b5ee5333aa6b7f5fc623b7d5f35f505cb7f974e98a70751cf41962f84c8c4637", - "03714c8bdaee0fb48f47babbc47c33e1880752b6620317c9d56b30f3b0ff58a9c3", - "020d35bbaf0a5abc8ec0ba33cde219fde734c63e7202098e1f9a6cf9daaeee55a9", - "027f7dec979482f418f01dfabddbd750ad036c579a16422125dd9a313eaa59c8e1", - "031d4cf1b7ab4c789b56c769f2888e4a61c778dfa5fe7e5cd0217fc41660b2eb65", - "0327e2cf1d2e516ecbfdbd616a87489cc92a73af97335d5c8c29eafb5d8882264a", - "03abbb3eff140cf3dce468b3fa5a28c80fa02c6703d7b952be6faaf2050990ebf4" - ] - }, - "prod": { - "conf": "http://conf.skywire.skycoin.com", - "dmsg_discovery": "http://dmsgd.skywire.skycoin.com", - "transport_discovery": "http://tpd.skywire.skycoin.com", - "address_resolver": "http://ar.skywire.skycoin.com", - "route_finder": "http://rf.skywire.skycoin.com", - "route_setup_nodes": [ - "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557", - "024fbd3997d4260f731b01abcfce60b8967a6d4c6a11d1008812810ea1437ce438", - "03b87c282f6e9f70d97aeea90b07cf09864a235ef718725632d067873431dd1015" - ], - "transport_setup": [ - "03530b786c670fc7f5ab9021478c7ec9cd06a03f3ea1416c50c4a8889ef5bba80e", - "03271c0de223b80400d9bd4b7722b536a245eb6c9c3176781ee41e7bac8f9bad21", - "03a792e6d960c88c6fb2184ee4f16714c58b55f0746840617a19f7dd6e021699d9", - "0313efedc579f57f05d4f5bc3fbf0261f31e51cdcfde7e568169acf92c78868926", - "025c7bbf23e3441a36d7e8a1e9d717921e2a49a2ce035680fec4808a048d244c8a", - "030eb6967f6e23e81db0d214f925fc5ce3371e1b059fb8379ae3eb1edfc95e0b46", - "02e582c0a5e5563aad47f561b272e4c3a9f7ac716258b58e58eb50afd83c286a7f", - "02ddc6c749d6ed067bb68df19c9bcb1a58b7587464043b1707398ffa26a9746b26", - "03aa0b1c4e23616872058c11c6efba777c130a85eaf909945d697399a1eb08426d", - "03adb2c924987d8deef04d02bd95236c5ae172fe5dfe7273e0461d96bf4bc220be" - ], - "uptime_tracker": "http://ut.skywire.skycoin.com", - "service_discovery": "http://sd.skycoin.com", - "stun_servers": [ - "139.162.30.112:3478", - "192.53.118.31:3478", - "192.53.118.61:3478", - "170.187.228.44:3478", - "170.187.228.178:3478", - "139.162.30.129:3478", - "192.53.118.134:3478", - "192.53.118.209:3478" - ], - "dns_server": "1.1.1.1", - "survey_whitelist": [ - "02b5ee5333aa6b7f5fc623b7d5f35f505cb7f974e98a70751cf41962f84c8c4637", - "03714c8bdaee0fb48f47babbc47c33e1880752b6620317c9d56b30f3b0ff58a9c3", - "020d35bbaf0a5abc8ec0ba33cde219fde734c63e7202098e1f9a6cf9daaeee55a9", - "027f7dec979482f418f01dfabddbd750ad036c579a16422125dd9a313eaa59c8e1", - "031d4cf1b7ab4c789b56c769f2888e4a61c778dfa5fe7e5cd0217fc41660b2eb65", - "0327e2cf1d2e516ecbfdbd616a87489cc92a73af97335d5c8c29eafb5d8882264a", - "03abbb3eff140cf3dce468b3fa5a28c80fa02c6703d7b952be6faaf2050990ebf4" - ] - } + "test": { + "conf": "http://conf.skywire.dev", + "dmsg_discovery": "http://dmsgd.skywire.dev", + "transport_discovery": "http://tpd.skywire.dev", + "address_resolver": "http://ar.skywire.dev", + "route_finder": "http://rf.skywire.dev", + "route_setup_nodes": [ + "026c2a3e92d6253c5abd71a42628db6fca9dd9aa037ab6f4e3a31108558dfd87cf" + ], + "transport_setup": [ + "03530b786c670fc7f5ab9021478c7ec9cd06a03f3ea1416c50c4a8889ef5bba80e", + "03271c0de223b80400d9bd4b7722b536a245eb6c9c3176781ee41e7bac8f9bad21", + "03a792e6d960c88c6fb2184ee4f16714c58b55f0746840617a19f7dd6e021699d9", + "0313efedc579f57f05d4f5bc3fbf0261f31e51cdcfde7e568169acf92c78868926", + "025c7bbf23e3441a36d7e8a1e9d717921e2a49a2ce035680fec4808a048d244c8a", + "030eb6967f6e23e81db0d214f925fc5ce3371e1b059fb8379ae3eb1edfc95e0b46", + "02e582c0a5e5563aad47f561b272e4c3a9f7ac716258b58e58eb50afd83c286a7f", + "02ddc6c749d6ed067bb68df19c9bcb1a58b7587464043b1707398ffa26a9746b26", + "03aa0b1c4e23616872058c11c6efba777c130a85eaf909945d697399a1eb08426d", + "03adb2c924987d8deef04d02bd95236c5ae172fe5dfe7273e0461d96bf4bc220be" + ], + "uptime_tracker": "http://ut.skywire.dev", + "service_discovery": "http://sd.skywire.dev", + "stun_servers": [ + "139.162.160.227:5349", + "139.162.173.101:5349" + ], + "dns_server": "1.1.1.1", + "survey_whitelist": [ + "02b5ee5333aa6b7f5fc623b7d5f35f505cb7f974e98a70751cf41962f84c8c4637", + "03714c8bdaee0fb48f47babbc47c33e1880752b6620317c9d56b30f3b0ff58a9c3", + "020d35bbaf0a5abc8ec0ba33cde219fde734c63e7202098e1f9a6cf9daaeee55a9", + "027f7dec979482f418f01dfabddbd750ad036c579a16422125dd9a313eaa59c8e1", + "031d4cf1b7ab4c789b56c769f2888e4a61c778dfa5fe7e5cd0217fc41660b2eb65", + "0327e2cf1d2e516ecbfdbd616a87489cc92a73af97335d5c8c29eafb5d8882264a", + "03abbb3eff140cf3dce468b3fa5a28c80fa02c6703d7b952be6faaf2050990ebf4" + ] + }, + "prod": { + "conf": "http://conf.skywire.skycoin.com", + "dmsg_discovery": "http://dmsgd.skywire.skycoin.com", + "transport_discovery": "http://tpd.skywire.skycoin.com", + "address_resolver": "http://ar.skywire.skycoin.com", + "route_finder": "http://rf.skywire.skycoin.com", + "route_setup_nodes": [ + "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557", + "024fbd3997d4260f731b01abcfce60b8967a6d4c6a11d1008812810ea1437ce438", + "03b87c282f6e9f70d97aeea90b07cf09864a235ef718725632d067873431dd1015" + ], + "transport_setup": [ + "03530b786c670fc7f5ab9021478c7ec9cd06a03f3ea1416c50c4a8889ef5bba80e", + "03271c0de223b80400d9bd4b7722b536a245eb6c9c3176781ee41e7bac8f9bad21", + "03a792e6d960c88c6fb2184ee4f16714c58b55f0746840617a19f7dd6e021699d9", + "0313efedc579f57f05d4f5bc3fbf0261f31e51cdcfde7e568169acf92c78868926", + "025c7bbf23e3441a36d7e8a1e9d717921e2a49a2ce035680fec4808a048d244c8a", + "030eb6967f6e23e81db0d214f925fc5ce3371e1b059fb8379ae3eb1edfc95e0b46", + "02e582c0a5e5563aad47f561b272e4c3a9f7ac716258b58e58eb50afd83c286a7f", + "02ddc6c749d6ed067bb68df19c9bcb1a58b7587464043b1707398ffa26a9746b26", + "03aa0b1c4e23616872058c11c6efba777c130a85eaf909945d697399a1eb08426d", + "03adb2c924987d8deef04d02bd95236c5ae172fe5dfe7273e0461d96bf4bc220be" + ], + "uptime_tracker": "http://ut.skywire.skycoin.com", + "service_discovery": "http://sd.skycoin.com", + "stun_servers": [ + "139.162.160.227:5349", + "139.162.173.101:5349" + ], + "dns_server": "1.1.1.1", + "survey_whitelist": [ + "02b5ee5333aa6b7f5fc623b7d5f35f505cb7f974e98a70751cf41962f84c8c4637", + "03714c8bdaee0fb48f47babbc47c33e1880752b6620317c9d56b30f3b0ff58a9c3", + "020d35bbaf0a5abc8ec0ba33cde219fde734c63e7202098e1f9a6cf9daaeee55a9", + "027f7dec979482f418f01dfabddbd750ad036c579a16422125dd9a313eaa59c8e1", + "031d4cf1b7ab4c789b56c769f2888e4a61c778dfa5fe7e5cd0217fc41660b2eb65", + "0327e2cf1d2e516ecbfdbd616a87489cc92a73af97335d5c8c29eafb5d8882264a", + "03abbb3eff140cf3dce468b3fa5a28c80fa02c6703d7b952be6faaf2050990ebf4" + ] + } }