From e82d056f50268cfe6c12cea32da3fd442ddd4199 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sun, 22 Sep 2024 11:09:37 -0500 Subject: [PATCH] fix golangci-lint errors --- cmd/apps/skychat/commands/skychat.go | 2 +- .../commands/skysocks-client.go | 2 +- cmd/apps/skysocks/commands/skysocks.go | 2 +- cmd/apps/vpn-client/commands/vpn-client.go | 2 +- cmd/skywire-cli/commands/config/gen.go | 6 +-- cmd/skywire-cli/commands/config/services.go | 6 +-- cmd/skywire-cli/commands/config/update.go | 8 ++-- cmd/skywire-cli/commands/log/log.go | 2 +- cmd/skywire-cli/commands/mdisc/root.go | 2 +- cmd/skywire-cli/commands/proxy/proxy.go | 16 ++++--- cmd/skywire-cli/commands/rewards/calc.go | 4 +- cmd/skywire-cli/commands/rewards/ui.go | 45 ++++++++++++++++++- cmd/skywire-cli/commands/root.go | 4 +- cmd/skywire-cli/commands/survey/root.go | 2 +- cmd/skywire-cli/commands/tp/tp.go | 4 +- cmd/skywire-cli/commands/visor/app.go | 4 +- cmd/skywire-cli/commands/visor/ping.go | 2 +- cmd/skywire-cli/commands/visor/process.go | 6 +-- cmd/skywire-cli/commands/vpn/vvpn.go | 2 +- cmd/skywire/skywire.go | 4 +- internal/skysocks/server_test.go | 2 +- pkg/app/appcommon/hello.go | 2 +- pkg/app/appserver/proc.go | 3 +- pkg/app/appserver/proc_manager.go | 2 +- pkg/app/idmanager/manager_test.go | 2 +- pkg/router/network_stats.go | 2 +- pkg/router/route_group.go | 12 ++--- pkg/router/router.go | 9 ++-- pkg/router/rpc_gateway_test.go | 12 ++--- pkg/router/setupmetrics/victoria_metrics.go | 2 +- pkg/routing/packet.go | 4 +- pkg/routing/rule.go | 2 +- pkg/routing/table.go | 2 +- pkg/servicedisc/types.go | 2 +- pkg/transport/handshake.go | 2 +- .../network/addrresolver/client_test.go | 5 ++- pkg/transport/network/handshake/handshake.go | 5 ++- pkg/transport/tpdclient/client_test.go | 17 ++++--- pkg/utclient/client_test.go | 6 ++- pkg/visor/hypervisor.go | 6 +-- pkg/visor/init.go | 2 +- pkg/visor/visorconfig/services.go | 4 +- pkg/visor/visorconfig/v1.go | 6 +-- 43 files changed, 147 insertions(+), 89 deletions(-) diff --git a/cmd/apps/skychat/commands/skychat.go b/cmd/apps/skychat/commands/skychat.go index becbe7d89b..d5ecf21abd 100644 --- a/cmd/apps/skychat/commands/skychat.go +++ b/cmd/apps/skychat/commands/skychat.go @@ -67,7 +67,7 @@ var RootCmd = &cobra.Command{ DisableSuggestions: true, DisableFlagsInUseLine: true, Version: buildinfo.Version(), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { appCl = app.NewClient(nil) defer appCl.Close() diff --git a/cmd/apps/skysocks-client/commands/skysocks-client.go b/cmd/apps/skysocks-client/commands/skysocks-client.go index 3c5332a00d..e844cc0332 100644 --- a/cmd/apps/skysocks-client/commands/skysocks-client.go +++ b/cmd/apps/skysocks-client/commands/skysocks-client.go @@ -60,7 +60,7 @@ var RootCmd = &cobra.Command{ DisableSuggestions: true, DisableFlagsInUseLine: true, Version: buildinfo.Version(), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { appCl := app.NewClient(nil) defer appCl.Close() diff --git a/cmd/apps/skysocks/commands/skysocks.go b/cmd/apps/skysocks/commands/skysocks.go index 223af2b02b..05a77e0351 100644 --- a/cmd/apps/skysocks/commands/skysocks.go +++ b/cmd/apps/skysocks/commands/skysocks.go @@ -44,7 +44,7 @@ var RootCmd = &cobra.Command{ DisableSuggestions: true, DisableFlagsInUseLine: true, Version: buildinfo.Version(), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { appCl := app.NewClient(nil) defer appCl.Close() diff --git a/cmd/apps/vpn-client/commands/vpn-client.go b/cmd/apps/vpn-client/commands/vpn-client.go index a93374dc96..ff1100d63b 100644 --- a/cmd/apps/vpn-client/commands/vpn-client.go +++ b/cmd/apps/vpn-client/commands/vpn-client.go @@ -55,7 +55,7 @@ var RootCmd = &cobra.Command{ DisableSuggestions: true, DisableFlagsInUseLine: true, Version: buildinfo.Version(), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var directIPsCh, nonDirectIPsCh = make(chan net.IP, 100), make(chan net.IP, 100) defer close(directIPsCh) diff --git a/cmd/skywire-cli/commands/config/gen.go b/cmd/skywire-cli/commands/config/gen.go index b1901870a7..c1967b7915 100644 --- a/cmd/skywire-cli/commands/config/gen.go +++ b/cmd/skywire-cli/commands/config/gen.go @@ -35,7 +35,7 @@ var checkPKCmd = &cobra.Command{ Use: "check-pk ", Short: "check a skywire public key", Args: cobra.ExactArgs(1), // Require exactly one argument - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) == 0 { return } @@ -52,7 +52,7 @@ var checkPKCmd = &cobra.Command{ var genKeysCmd = &cobra.Command{ Use: "gen-keys", Short: "generate public / secret keypair", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { pk, sk := cipher.GenerateKeyPair() fmt.Println(pk) fmt.Println(sk) @@ -379,7 +379,7 @@ var genConfigCmd = &cobra.Command{ } } }, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { log := logger wasStdout := isStdout diff --git a/cmd/skywire-cli/commands/config/services.go b/cmd/skywire-cli/commands/config/services.go index b76a813df9..75dc63b080 100644 --- a/cmd/skywire-cli/commands/config/services.go +++ b/cmd/skywire-cli/commands/config/services.go @@ -25,7 +25,7 @@ func init() { var servicesCmd = &cobra.Command{ Use: "svc", Short: "update services-config.json file from config bootstrap service", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { log := logging.MustGetLogger("services_updater") ctx, cancel := cmdutil.SignalContext(context.Background(), log) @@ -56,7 +56,7 @@ var servicesCmd = &cobra.Command{ func fetchServicesConf() (servicesConf, error) { var newConf servicesConf var prodConf visorconfig.Services - prodResp, err := http.Get(serviceConfURL) + prodResp, err := http.Get(serviceConfURL) //nolint if err != nil { return newConf, err } @@ -72,7 +72,7 @@ func fetchServicesConf() (servicesConf, error) { newConf.Prod = prodConf var testConf visorconfig.Services - testResp, err := http.Get(testServiceConfURL) + testResp, err := http.Get(testServiceConfURL) //nolint if err != nil { return newConf, err } diff --git a/cmd/skywire-cli/commands/config/update.go b/cmd/skywire-cli/commands/config/update.go index dc8fa35490..c243b297fb 100644 --- a/cmd/skywire-cli/commands/config/update.go +++ b/cmd/skywire-cli/commands/config/update.go @@ -32,7 +32,7 @@ func init() { updateCmd.Flags().SortFlags = false updateCmd.Flags().BoolVarP(&isUpdateEndpoints, "endpoints", "a", false, "update server endpoints") updateCmd.Flags().StringVar(&logLevel, "log-level", "", "level of logging in config") - updateCmd.Flags().StringVarP(&serviceConfURL, "url", "b", skywire.ConfService, "service config URL") + updateCmd.Flags().StringVarP(&serviceConfURL, "url", "b", skywire.ProdConf.Conf, "service config URL") updateCmd.Flags().BoolVarP(&isTestEnv, "testenv", "t", false, "use test deployment") updateCmd.Flags().StringVar(&setPublicAutoconnect, "public-autoconn", "", "change public autoconnect configuration") updateCmd.Flags().IntVar(&minHops, "set-minhop", -1, "change min hops value") @@ -92,9 +92,9 @@ var updateCmd = &cobra.Command{ PreRun: func(_ *cobra.Command, _ []string) { if isUpdateEndpoints && (serviceConfURL == "") { if !isTestEnv { - serviceConfURL = skywire.ConfService + serviceConfURL = skywire.ProdConf.Conf } else { - serviceConfURL = skywire.ConfServiceTest + serviceConfURL = skywire.TestConf.Conf } } setDefaults() @@ -107,7 +107,7 @@ var updateCmd = &cobra.Command{ conf = initUpdate() if isUpdateEndpoints { if isTestEnv { - serviceConfURL = skywire.ConfServiceTest + serviceConfURL = skywire.TestConf.Conf } mLog := logging.NewMasterLogger() mLog.SetLevel(logrus.InfoLevel) diff --git a/cmd/skywire-cli/commands/log/log.go b/cmd/skywire-cli/commands/log/log.go index 215902d5c7..d5f7c376c9 100644 --- a/cmd/skywire-cli/commands/log/log.go +++ b/cmd/skywire-cli/commands/log/log.go @@ -63,7 +63,7 @@ var logCmd = &cobra.Command{ Use: "log", Short: "survey & transport log collection", Long: "Fetch health, survey, and transport logging from visors which are online in the uptime tracker\nhttp://ut.skywire.skycoin.com/uptimes?v=v2\nhttp://ut.skywire.skycoin.com/uptimes?v=v2&visors=;;", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { log := logging.MustGetLogger("log-collecting") fver, err := version.NewVersion("v1.3.17") if err != nil { diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index 2de25db765..cd910dd146 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -61,7 +61,7 @@ var RootCmd = &cobra.Command{ Short: "Query DMSG Discovery", Long: `Query DMSG Discovery list entries in dmsg discovery`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { dmsgclientkeys := internal.GetData(cacheFileDMSGD, mdURL+"/dmsg-discovery/entries", cacheFilesAge) if isStats { stats, _ := script.Echo(dmsgclientkeys).JQ(".[]").CountLines() //nolint diff --git a/cmd/skywire-cli/commands/proxy/proxy.go b/cmd/skywire-cli/commands/proxy/proxy.go index 2671a6ef0d..c09996809a 100644 --- a/cmd/skywire-cli/commands/proxy/proxy.go +++ b/cmd/skywire-cli/commands/proxy/proxy.go @@ -173,7 +173,7 @@ var startCmd = &cobra.Command{ var stopCmd = &cobra.Command{ Use: "stop", Short: "stop the " + serviceType + " client", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { internal.PrintFatalError(cmd.Flags(), fmt.Errorf("unable to create RPC client: %w", err)) @@ -197,7 +197,7 @@ var stopCmd = &cobra.Command{ var statusCmd = &cobra.Command{ Use: "status", Short: serviceType + " client status", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { //TODO: check status of multiple clients rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { @@ -217,7 +217,10 @@ var statusCmd = &cobra.Command{ AppPort routing.Port `json:"app_port"` } var jsonAppStatus []appState - fmt.Fprintf(w, "---- All Proxy List -----------------------------------------------------\n\n") + _, err = fmt.Fprintf(w, "---- All Proxy List -----------------------------------------------------\n\n") + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("error on fmt.Fprintf: %w", err)) + } for _, state := range states { for _, v := range state.AppConfig.Args { if v == binaryName { @@ -250,7 +253,10 @@ var statusCmd = &cobra.Command{ } } } - fmt.Fprintf(w, "-------------------------------------------------------------------------\n") + _, err = fmt.Fprintf(w, "-------------------------------------------------------------------------\n") + if err != nil { + internal.PrintFatalError(cmd.Flags(), fmt.Errorf("error on fmt.Fprintf: %w", err)) + } internal.Catch(cmd.Flags(), w.Flush()) internal.PrintOutput(cmd.Flags(), jsonAppStatus, b.String()) }, @@ -290,7 +296,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: "List servers", Long: fmt.Sprintf("List %v servers from service discovery\n%v/api/services?type=%v\n%v/api/services?type=%v&country=US\n\nSet cache file location to \"\" to avoid using cache files", serviceType, svcDiscURL, serviceType, svcDiscURL, serviceType), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { sds := internal.GetData(cacheFileSD, sdURL+"/api/services?type="+serviceType, cacheFilesAge) if rawData { script.Echo(string(pretty.Color(pretty.Pretty([]byte(sds)), nil))).Stdout() //nolint diff --git a/cmd/skywire-cli/commands/rewards/calc.go b/cmd/skywire-cli/commands/rewards/calc.go index 5c3964033e..c83cddb266 100644 --- a/cmd/skywire-cli/commands/rewards/calc.go +++ b/cmd/skywire-cli/commands/rewards/calc.go @@ -93,7 +93,7 @@ var RootCmd = &cobra.Command{ Long: ` Collect surveys: skywire-cli log Fetch uptimes: skywire-cli ut > ut.txt`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var err error if log == nil { log = logging.MustGetLogger("rewards") @@ -406,7 +406,7 @@ func init() { var testCmd = &cobra.Command{ Use: "svc", Short: "verify services in survey", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var err error if log == nil { log = logging.MustGetLogger("rewards") diff --git a/cmd/skywire-cli/commands/rewards/ui.go b/cmd/skywire-cli/commands/rewards/ui.go index eabb1af321..db23b006aa 100644 --- a/cmd/skywire-cli/commands/rewards/ui.go +++ b/cmd/skywire-cli/commands/rewards/ui.go @@ -49,7 +49,7 @@ func init() { uiCmd, ) uiCmd.Flags().UintVarP(&webPort, "port", "p", scriptExecUint("${WEBPORT:-80}"), "port to serve") - uiCmd.Flags().UintVarP(&dmsgPort, "dport", "d", scriptExecUint("${DMSGPORT:-80}"), "dmsg port to serve") + uiCmd.Flags().Uint16VarP(&dmsgPort, "dport", "d", scriptExecUint16("${DMSGPORT:-80}"), "dmsg port to serve") uiCmd.Flags().IntVarP(&dmsgSess, "dsess", "e", scriptExecInt("${DMSGSESSIONS:-1}"), "dmsg sessions") msg := "add whitelist keys, comma separated to permit POST of reward transaction to be broadcast" if scriptExecArray("${REWARDPKS[@]}") != "" { @@ -95,7 +95,7 @@ var ( runTime time.Duration sk cipher.SecKey dmsgDisc string - dmsgPort uint + dmsgPort uint16 dmsgSess int wl string wlkeys []cipher.PubKey @@ -1506,6 +1506,47 @@ func scriptExecUint(s string) uint { return uint(0) } +func scriptExecUint16(s string) uint16 { + if runtime.GOOS == "windows" { + var variable string + if strings.Contains(s, ":-") { + parts := strings.SplitN(s, ":-", 2) + variable = parts[0] + "}" + } else { + variable = s + } + out, err := script.Exec(fmt.Sprintf(`powershell -c '$SKYENV = "%s"; if ($SKYENV -ne "" -and (Test-Path $SKYENV)) { . $SKYENV }; echo %s"`, skyenvfile, variable)).String() + if err == nil { + if (out == "") || (out == variable) { + return 0 + } + i, err := strconv.Atoi(strings.TrimSpace(strings.TrimRight(out, "\n"))) + if err == nil { + if i >= 0 && i <= 65535 { + return uint16(i) //nolint + } + return 0 + } + return 0 + } + return 0 + } + z, err := script.Exec(fmt.Sprintf(`bash -c 'SKYENV=%s ; if [[ $SKYENV != "" ]] && [[ -f $SKYENV ]] ; then source $SKYENV ; fi ; printf "%s"'`, skyenvfile, s)).String() + if err == nil { + if z == "" { + return 0 + } + i, err := strconv.Atoi(z) + if err == nil { + if i >= 0 && i <= 65535 { + return uint16(i) //nolint + } + return 0 + } + } + return uint16(0) +} + func whitelistAuth(whitelistedPKs []cipher.PubKey) gin.HandlerFunc { return func(c *gin.Context) { // Get the remote PK. diff --git a/cmd/skywire-cli/commands/root.go b/cmd/skywire-cli/commands/root.go index dee47484c0..5a04199f87 100644 --- a/cmd/skywire-cli/commands/root.go +++ b/cmd/skywire-cli/commands/root.go @@ -84,7 +84,7 @@ var treeCmd = &cobra.Command{ SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // You can use a LeveledList here, for easy generation. leveledList := pterm.LeveledList{} leveledList = append(leveledList, pterm.LeveledListItem{Level: 0, Text: RootCmd.Use}) @@ -140,7 +140,7 @@ var docCmd = &cobra.Command{ SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("\n# %s\n", "skywire-cli documentation") fmt.Printf("\n%s\n", "skywire command line interface") diff --git a/cmd/skywire-cli/commands/survey/root.go b/cmd/skywire-cli/commands/survey/root.go index 75abbc2e57..35edafd95b 100644 --- a/cmd/skywire-cli/commands/survey/root.go +++ b/cmd/skywire-cli/commands/survey/root.go @@ -71,7 +71,7 @@ var surveyCmd = &cobra.Command{ DisableFlagsInUseLine: true, Short: "system survey", Long: "print the system survey", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if pkg { confPath = visorconfig.SkywirePath + "/" + visorconfig.ConfigJSON } diff --git a/cmd/skywire-cli/commands/tp/tp.go b/cmd/skywire-cli/commands/tp/tp.go index a6bc7aa0b5..4d49b55625 100644 --- a/cmd/skywire-cli/commands/tp/tp.go +++ b/cmd/skywire-cli/commands/tp/tp.go @@ -251,7 +251,7 @@ var rmTpCmd = &cobra.Command{ Short: "Remove transport(s) by id", Long: "\n Remove transport(s) by id", DisableFlagsInUseLine: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if removeAll { internal.Catch(cmd.Flags(), rpcClient.RemoveAllTransports()) @@ -439,7 +439,7 @@ var treeCmd = &cobra.Command{ Use: "tree", Short: "tree map of transports on the skywire network", Long: fmt.Sprintf("display a tree representation of transports from TPD\n\n%v/all-transports\n\nSet cache file location to \"\" to avoid using cache files", tpDiscURL), - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { if rootNode != "" { err := rootnode.Set(rootNode) if err != nil { diff --git a/cmd/skywire-cli/commands/visor/app.go b/cmd/skywire-cli/commands/visor/app.go index 4cea5061a9..7468fbea05 100644 --- a/cmd/skywire-cli/commands/visor/app.go +++ b/cmd/skywire-cli/commands/visor/app.go @@ -142,7 +142,7 @@ var registerAppCmd = &cobra.Command{ Use: "register", Short: "Register app", Long: "\n Register app", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { os.Exit(1) @@ -175,7 +175,7 @@ var deregisterAppCmd = &cobra.Command{ Use: "deregister", Short: "Deregister app", Long: "\n Deregister app", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { os.Exit(1) diff --git a/cmd/skywire-cli/commands/visor/ping.go b/cmd/skywire-cli/commands/visor/ping.go index 464077bf20..4cb83a4a68 100644 --- a/cmd/skywire-cli/commands/visor/ping.go +++ b/cmd/skywire-cli/commands/visor/ping.go @@ -58,7 +58,7 @@ var testCmd = &cobra.Command{ Use: "test", Short: "Test the visor with public visors on network", Long: "\n Creates a route with public visors as a hop and returns latency on the conn", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { pingConfig := visor.PingConfig{Tries: tries, PcktSize: pcktSize, PubVisCount: pubVisCount} rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { diff --git a/cmd/skywire-cli/commands/visor/process.go b/cmd/skywire-cli/commands/visor/process.go index 006e9705af..32aa05f1c3 100644 --- a/cmd/skywire-cli/commands/visor/process.go +++ b/cmd/skywire-cli/commands/visor/process.go @@ -37,7 +37,7 @@ func init() { var startCmd = &cobra.Command{ Use: "start", Short: "start visor", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { var output string var err error if !sourcerun { @@ -71,7 +71,7 @@ var reloadCmd = &cobra.Command{ Use: "reload", Short: "reload visor", Hidden: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { os.Exit(1) @@ -97,7 +97,7 @@ var shutdownCmd = &cobra.Command{ Use: "halt", Short: "Stop a running visor", Long: "\n Stop a running visor", - Run: func(cmd *cobra.Command, args []string) { + Run: func(cmd *cobra.Command, _ []string) { rpcClient, err := clirpc.Client(cmd.Flags()) if err != nil { os.Exit(1) diff --git a/cmd/skywire-cli/commands/vpn/vvpn.go b/cmd/skywire-cli/commands/vpn/vvpn.go index c8739d6acf..0de39a9b37 100644 --- a/cmd/skywire-cli/commands/vpn/vvpn.go +++ b/cmd/skywire-cli/commands/vpn/vvpn.go @@ -197,7 +197,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: "List servers", Long: fmt.Sprintf("List %v servers from service discovery\n%v/api/services?type=%v\n%v/api/services?type=%v&country=US\n\nSet cache file location to \"\" to avoid using cache files", serviceType, sdURL, serviceType, sdURL, serviceType), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { sds := internal.GetData(cacheFileSD, sdURL+"/api/services?type="+serviceType, cacheFilesAge) if rawData { script.Echo(string(pretty.Color(pretty.Pretty([]byte(sds)), nil))).Stdout() //nolint diff --git a/cmd/skywire/skywire.go b/cmd/skywire/skywire.go index 3232213cb6..719067e9ad 100644 --- a/cmd/skywire/skywire.go +++ b/cmd/skywire/skywire.go @@ -210,7 +210,7 @@ var treeCmd = &cobra.Command{ SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { // You can use a LeveledList here, for easy generation. leveledList := pterm.LeveledList{} leveledList = append(leveledList, pterm.LeveledListItem{Level: 0, Text: RootCmd.Use}) @@ -270,7 +270,7 @@ var docCmd = &cobra.Command{ SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("\n# %s\n", "skywire documentation") fmt.Printf("\n## %s\n", "subcommand tree") fmt.Printf("\n%s\n", "A tree representation of the skywire subcommands") diff --git a/internal/skysocks/server_test.go b/internal/skysocks/server_test.go index 809a8175ff..1306d81030 100644 --- a/internal/skysocks/server_test.go +++ b/internal/skysocks/server_test.go @@ -70,7 +70,7 @@ func TestProxy(t *testing.T) { proxyDial, err := proxy.SOCKS5("tcp", ":10080", nil, proxy.Direct) require.NoError(t, err) - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := fmt.Fprintln(w, "Hello, client") require.NoError(t, err) })) diff --git a/pkg/app/appcommon/hello.go b/pkg/app/appcommon/hello.go index 807d73ecf1..a648d15d6e 100644 --- a/pkg/app/appcommon/hello.go +++ b/pkg/app/appcommon/hello.go @@ -63,7 +63,7 @@ func WriteHello(w io.Writer, hello Hello) error { raw := make([]byte, 2+len(helloRaw)) size := len(helloRaw) - binary.BigEndian.PutUint16(raw[:2], uint16(size)) + binary.BigEndian.PutUint16(raw[:2], uint16(size)) //nolint if n := copy(raw[2:], helloRaw); n != size { panic("hello write does not add up") } diff --git a/pkg/app/appserver/proc.go b/pkg/app/appserver/proc.go index cd6d0d0b08..96b6f9d210 100644 --- a/pkg/app/appserver/proc.go +++ b/pkg/app/appserver/proc.go @@ -439,7 +439,8 @@ func (p *Proc) ConnectionsSummary() []ConnectionSummary { } var summaries []ConnectionSummary - rpcGW.cm.DoRange(func(id uint16, v interface{}) bool { + // rpcGW.cm.DoRange(func(id uint16, v interface{}) bool { + rpcGW.cm.DoRange(func(_ uint16, v interface{}) bool { if v == nil { summaries = append(summaries, ConnectionSummary{}) return true diff --git a/pkg/app/appserver/proc_manager.go b/pkg/app/appserver/proc_manager.go index 357dde3bb5..b79e6278ff 100644 --- a/pkg/app/appserver/proc_manager.go +++ b/pkg/app/appserver/proc_manager.go @@ -221,7 +221,7 @@ func (m *procManager) Start(conf appcommon.ProcConfig) (appcommon.ProcID, error) return 0, err } delete(m.errors, conf.AppName) - return appcommon.ProcID(proc.cmd.Process.Pid), nil + return appcommon.ProcID(proc.cmd.Process.Pid), nil //nolint } // Register registers a proc for an external app. diff --git a/pkg/app/idmanager/manager_test.go b/pkg/app/idmanager/manager_test.go index c570754a5f..e69f32ca47 100644 --- a/pkg/app/idmanager/manager_test.go +++ b/pkg/app/idmanager/manager_test.go @@ -426,7 +426,7 @@ func TestManager_DoRange(t *testing.T) { } for i, v := range vals { - _, err := m.Add(uint16(i), v) + _, err := m.Add(uint16(i), v) //nolint require.NoError(t, err) } diff --git a/pkg/router/network_stats.go b/pkg/router/network_stats.go index f954ec2a1b..c151e3ef12 100644 --- a/pkg/router/network_stats.go +++ b/pkg/router/network_stats.go @@ -32,7 +32,7 @@ func (s *networkStats) SetLatency(latency uint32) { func (s *networkStats) Latency() time.Duration { latencyMs := atomic.LoadUint32(&s.latency) // the latency is store in uint32 of millisecond but time.Duration takes nanosecond - return time.Duration(latencyMs * uint32(time.Millisecond.Nanoseconds())) + return time.Duration(latencyMs * uint32(time.Millisecond.Nanoseconds())) //nolint } func (s *networkStats) SetUploadSpeed(speed uint32) { diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index 9b8293e9b0..ca694c4a02 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -449,7 +449,7 @@ func (rg *RouteGroup) sendPing() error { throughput := rg.networkStats.RemoteThroughput() timestamp := time.Now().UTC().UnixNano() / int64(time.Millisecond) - rg.networkStats.SetDownloadSpeed(uint32(throughput)) + rg.networkStats.SetDownloadSpeed(uint32(throughput)) //nolint packet := routing.MakePingPacket(rule.NextRouteID(), timestamp, throughput) @@ -697,7 +697,7 @@ func (rg *RouteGroup) handleErrorPacket(packet routing.Packet) error { return nil } - rg.SetError(fmt.Errorf(string(packet.Payload()))) + rg.SetError(fmt.Errorf("%v", string(packet.Payload()))) return nil } @@ -723,9 +723,9 @@ func (rg *RouteGroup) handlePingPacket(packet routing.Packet) error { rg.logger.WithField("func", "RouteGroup.handlePingPacket").Tracef("Throughput is around %d", throughput) - rg.networkStats.SetUploadSpeed(uint32(throughput)) + rg.networkStats.SetUploadSpeed(uint32(throughput)) //nolint - return rg.sendPong(int64(timestamp)) + return rg.sendPong(int64(timestamp)) //nolint } func (rg *RouteGroup) handlePongPacket(packet routing.Packet) error { @@ -734,13 +734,13 @@ func (rg *RouteGroup) handlePongPacket(packet routing.Packet) error { sentAtMs := binary.BigEndian.Uint64(payload) ms := sentAtMs % 1000 - sentAt := time.Unix(int64(sentAtMs/1000), int64(ms)*int64(time.Millisecond)).UTC() + sentAt := time.Unix(int64(sentAtMs/1000), int64(ms)*int64(time.Millisecond)).UTC() //nolint latency := time.Now().UTC().Sub(sentAt).Milliseconds() rg.logger.WithField("func", "RouteGroup.handlePongPacket").Tracef("Latency is around %d ms", latency) - rg.networkStats.SetLatency(uint32(latency)) + rg.networkStats.SetLatency(uint32(latency)) //nolint return nil } diff --git a/pkg/router/router.go b/pkg/router/router.go index c18f28b22f..45a99a36b7 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -990,11 +990,11 @@ func (r *router) forwardPacket(ctx context.Context, packet routing.Packet, rule case routing.ClosePacket: p = routing.MakeClosePacket(rule.NextRouteID(), routing.CloseCode(packet.Payload()[0])) case routing.PingPacket: - timestamp := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset:])) - throughput := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset+8:])) + timestamp := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset:])) //nolint + throughput := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset+8:])) //nolint p = routing.MakePingPacket(rule.NextRouteID(), timestamp, throughput) case routing.PongPacket: - timestamp := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset:])) + timestamp := int64(binary.BigEndian.Uint64(packet[routing.PacketPayloadOffset:])) //nolint p = routing.MakePongPacket(rule.NextRouteID(), timestamp) case routing.ErrorPacket: var err error @@ -1328,7 +1328,8 @@ func (r *router) removeRouteGroupOfRule(rule routing.Rule) { } func (r *router) checkIfTransportAvailable() (ok bool) { - r.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + // r.tm.WalkTransports(func(tp *transport.ManagedTransport) bool { + r.tm.WalkTransports(func(_ *transport.ManagedTransport) bool { ok = true return ok }) diff --git a/pkg/router/rpc_gateway_test.go b/pkg/router/rpc_gateway_test.go index 7752d4ff13..a0d14c8bf7 100644 --- a/pkg/router/rpc_gateway_test.go +++ b/pkg/router/rpc_gateway_test.go @@ -123,10 +123,10 @@ func TestRPCGateway_ReserveIDs(t *testing.T) { gateway := NewRPCGateway(r, mlog) - var gotIds []routing.RouteID - err := gateway.ReserveIDs(uint8(n), &gotIds) + var gotIDs []routing.RouteID + err := gateway.ReserveIDs(uint8(n), &gotIDs) //nolint require.NoError(t, err) - require.Equal(t, ids, gotIds) + require.Equal(t, ids, gotIDs) }) t.Run("fail reserving keys", func(t *testing.T) { @@ -140,9 +140,9 @@ func TestRPCGateway_ReserveIDs(t *testing.T) { Msg: testhelpers.Err.Error(), } - var gotIds []routing.RouteID - err := gateway.ReserveIDs(uint8(n), &gotIds) + var gotIDs []routing.RouteID + err := gateway.ReserveIDs(uint8(n), &gotIDs) //nolint require.Equal(t, wantErr, err) - require.Nil(t, gotIds) + require.Nil(t, gotIDs) }) } diff --git a/pkg/router/setupmetrics/victoria_metrics.go b/pkg/router/setupmetrics/victoria_metrics.go index 32f32e9aca..6a2b592929 100644 --- a/pkg/router/setupmetrics/victoria_metrics.go +++ b/pkg/router/setupmetrics/victoria_metrics.go @@ -43,7 +43,7 @@ func (m *VictoriaMetrics) RecordRequest() func(rules *routing.EdgeRules, err *er start := time.Now() m.activeRequests.Inc() - return func(rules *routing.EdgeRules, err *error) { + return func(_ *routing.EdgeRules, err *error) { if *err == nil { m.reqDurationsSuccesses.UpdateDuration(start) } else { diff --git a/pkg/routing/packet.go b/pkg/routing/packet.go index d75502815c..5fbd602a65 100644 --- a/pkg/routing/packet.go +++ b/pkg/routing/packet.go @@ -105,7 +105,7 @@ func MakeDataPacket(id RouteID, payload []byte) (Packet, error) { packet[PacketTypeOffset] = byte(DataPacket) binary.BigEndian.PutUint32(packet[PacketRouteIDOffset:], uint32(id)) - binary.BigEndian.PutUint16(packet[PacketPayloadSizeOffset:], uint16(len(payload))) + binary.BigEndian.PutUint16(packet[PacketPayloadSizeOffset:], uint16(len(payload))) //nolint copy(packet[PacketPayloadOffset:], payload) return packet, nil @@ -187,7 +187,7 @@ func MakeErrorPacket(id RouteID, errPayload []byte) (Packet, error) { packet[PacketTypeOffset] = byte(ErrorPacket) binary.BigEndian.PutUint32(packet[PacketRouteIDOffset:], uint32(id)) - binary.BigEndian.PutUint16(packet[PacketPayloadSizeOffset:], uint16(len(errPayload))) + binary.BigEndian.PutUint16(packet[PacketPayloadSizeOffset:], uint16(len(errPayload))) //nolint copy(packet[PacketPayloadOffset:], errPayload) return packet, nil diff --git a/pkg/routing/rule.go b/pkg/routing/rule.go index 1d0b091fc8..6aa22cfec8 100644 --- a/pkg/routing/rule.go +++ b/pkg/routing/rule.go @@ -65,7 +65,7 @@ func (r Rule) assertLen(l int) { // KeepAlive returns rule's keep-alive timeout. func (r Rule) KeepAlive() time.Duration { r.assertLen(RuleHeaderSize) - return time.Duration(binary.BigEndian.Uint64(r[0:8])) + return time.Duration(binary.BigEndian.Uint64(r[0:8])) //nolint } // setKeepAlive sets rule's keep-alive timeout. diff --git a/pkg/routing/table.go b/pkg/routing/table.go index bc85fe8695..954986abb1 100644 --- a/pkg/routing/table.go +++ b/pkg/routing/table.go @@ -92,7 +92,7 @@ func (mt *memTable) reserveKeysImpl(n int) (first, last RouteID, err error) { } first = mt.nextID + 1 - mt.nextID += RouteID(n) + mt.nextID += RouteID(n) //nolint last = mt.nextID return first, last, nil diff --git a/pkg/servicedisc/types.go b/pkg/servicedisc/types.go index b3d44ec58e..9e9b2c5b40 100644 --- a/pkg/servicedisc/types.go +++ b/pkg/servicedisc/types.go @@ -82,7 +82,7 @@ func (a *SWAddr) UnmarshalText(text []byte) error { if err != nil { return err } - binary.BigEndian.PutUint16(a[len(a)-2:], uint16(port)) + binary.BigEndian.PutUint16(a[len(a)-2:], uint16(port)) //nolint return nil } diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index ab3636584f..a773da678a 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -96,7 +96,7 @@ func (hs SettlementHS) Do(ctx context.Context, dc DiscoveryClient, transport net // The handshake logic only REGISTERS the transport, and does not update the status of the transport. func MakeSettlementHS(init bool, log *logging.Logger) SettlementHS { // initiating logic. - initHS := func(ctx context.Context, dc DiscoveryClient, transport network.Transport, sk cipher.SecKey) (err error) { + initHS := func(ctx context.Context, dc DiscoveryClient, transport network.Transport, sk cipher.SecKey) (err error) { //nolint entry := makeEntryFromTransport(transport) // create signed entry and send it to responding visor. diff --git a/pkg/transport/network/addrresolver/client_test.go b/pkg/transport/network/addrresolver/client_test.go index c80473a20d..7f1b1655e4 100644 --- a/pkg/transport/network/addrresolver/client_test.go +++ b/pkg/transport/network/addrresolver/client_test.go @@ -74,7 +74,7 @@ func TestBind(t *testing.T) { testPubKey, testSecKey := cipher.GenerateKeyPair() urlCh := make(chan string, 1) - srv := httptest.NewServer(authHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(authHandler(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { urlCh <- r.URL.String() }))) @@ -95,7 +95,8 @@ func authHandler(next http.Handler) http.Handler { r := chi.NewRouter() r.Handle("/security/nonces/{pk}", http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(&httpauth.NextNonceResponse{Edge: testPubKey, NextNonce: 1}); err != nil { log.WithError(err).Error("Failed to encode nonce response") } diff --git a/pkg/transport/network/handshake/handshake.go b/pkg/transport/network/handshake/handshake.go index 125c6e325b..46fccfc77b 100644 --- a/pkg/transport/network/handshake/handshake.go +++ b/pkg/transport/network/handshake/handshake.go @@ -64,7 +64,7 @@ type Handshake func(conn net.Conn, deadline time.Time) (lAddr, rAddr dmsg.Addr, // InitiatorHandshake creates the handshake logic on the initiator's side. func InitiatorHandshake(lSK cipher.SecKey, localAddr, remoteAddr dmsg.Addr) Handshake { - return handshakeMiddleware(func(conn net.Conn, deadline time.Time) (lAddr, rAddr dmsg.Addr, err error) { + return handshakeMiddleware(func(conn net.Conn, _ time.Time) (lAddr, rAddr dmsg.Addr, err error) { if err = writeFrame0(conn); err != nil { return dmsg.Addr{}, dmsg.Addr{}, err } @@ -113,7 +113,8 @@ func MakeF2PortChecker(portChecker func(port uint16) error) CheckF2 { // ResponderHandshake creates the handshake logic on the responder's side. func ResponderHandshake(checkF2 CheckF2) Handshake { - return handshakeMiddleware(func(conn net.Conn, deadline time.Time) (lAddr, rAddr dmsg.Addr, err error) { + // return handshakeMiddleware(func(conn net.Conn, deadline time.Time) (lAddr, rAddr dmsg.Addr, err error) { + return handshakeMiddleware(func(conn net.Conn, _ time.Time) (lAddr, rAddr dmsg.Addr, err error) { if err = readFrame0(conn); err != nil { return dmsg.Addr{}, dmsg.Addr{}, err } diff --git a/pkg/transport/tpdclient/client_test.go b/pkg/transport/tpdclient/client_test.go index 230317215b..3f75143a1c 100644 --- a/pkg/transport/tpdclient/client_test.go +++ b/pkg/transport/tpdclient/client_test.go @@ -101,7 +101,7 @@ func TestRegisterTransportResponses(t *testing.T) { }{ { "StatusCreated", - func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusCreated) }, + func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusCreated) }, func(err error) { require.NoError(t, err) }, }, // TODO(evaninjin): Not sure why this is failing and why this is expected behavior. @@ -112,12 +112,14 @@ func TestRegisterTransportResponses(t *testing.T) { //}, { "StatusInternalServerError", - func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) }, + // func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) }, + func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusInternalServerError) }, func(err error) { require.Error(t, err) }, }, { "JSONError", - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusInternalServerError) require.NoError(t, json.NewEncoder(w).Encode(JSONError{Error: "boom"})) }, @@ -129,7 +131,8 @@ func TestRegisterTransportResponses(t *testing.T) { }, { "NonJSONError", - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusInternalServerError) _, err := fmt.Fprintf(w, "boom") require.NoError(t, err) @@ -142,7 +145,8 @@ func TestRegisterTransportResponses(t *testing.T) { }, { "Request", - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(_ http.ResponseWriter, r *http.Request) { assert.Equal(t, http.MethodPost, r.Method) assert.Equal(t, "/transports/", r.URL.String()) }, @@ -229,7 +233,8 @@ func authHandler(t *testing.T, next http.Handler) http.Handler { r := chi.NewRouter() r.Handle("/security/nonces/{pk}", http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(w http.ResponseWriter, _ *http.Request) { require.NoError(t, json.NewEncoder(w).Encode(&httpauth.NextNonceResponse{Edge: testPubKey, NextNonce: 1})) }, )) diff --git a/pkg/utclient/client_test.go b/pkg/utclient/client_test.go index 3fcc4c94b2..626a4415ae 100644 --- a/pkg/utclient/client_test.go +++ b/pkg/utclient/client_test.go @@ -67,7 +67,8 @@ func TestClientAuth(t *testing.T) { func TestUpdateVisorUptime(t *testing.T) { urlCh := make(chan string, 1) - srv := httptest.NewServer(authHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // srv := httptest.NewServer(authHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(authHandler(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { urlCh <- r.URL.String() }))) @@ -86,7 +87,8 @@ func authHandler(next http.Handler) http.Handler { r := chi.NewRouter() log := logging.MustGetLogger("utclient") r.Handle("/security/nonces/{pk}", http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { + // func(w http.ResponseWriter, r *http.Request) { + func(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(&httpauth.NextNonceResponse{Edge: testPubKey, NextNonce: 1}); err != nil { log.WithError(err).Error("Failed to encode nonce response") } diff --git a/pkg/visor/hypervisor.go b/pkg/visor/hypervisor.go index 8ebbfebdea..182b4e5010 100644 --- a/pkg/visor/hypervisor.go +++ b/pkg/visor/hypervisor.go @@ -179,7 +179,7 @@ func (hv *Hypervisor) AddMockData(config MockConfig) error { hv.remoteVisors[pk] = Conn{ Addr: dmsg.Addr{ PK: pk, - Port: uint16(i), + Port: uint16(i), //nolint }, API: client, } @@ -1111,7 +1111,7 @@ func (hv *Hypervisor) deleteRoutes() http.HandlerFunc { } continue } - routeID := routing.RouteID(ridUint64) + routeID := routing.RouteID(ridUint64) //nolint contains := false for _, rule := range rules { if rule.KeyRouteID() == routeID { @@ -1502,7 +1502,7 @@ func ridFromParam(r *http.Request, key string) (routing.RouteID, error) { return 0, errors.New("invalid route ID provided") } - return routing.RouteID(rid), nil + return routing.RouteID(rid), nil //nolint } func strSliceFromQuery(r *http.Request, key string, defaultVal []string) []string { diff --git a/pkg/visor/init.go b/pkg/visor/init.go index 9ff6687433..c793712ade 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -640,7 +640,7 @@ func initSkywireForwardConn(ctx context.Context, v *Visor, log *logging.Logger) log.Debug("Accepting sky forwarding conn...") conn, err := l.Accept() if err != nil { - if !errors.Is(appnet.ErrClosedConn, err) { + if !errors.Is(err, appnet.ErrClosedConn) { log.WithError(err).Error("Failed to accept conn") } return diff --git a/pkg/visor/visorconfig/services.go b/pkg/visor/visorconfig/services.go index e448fe4410..c3f3c4c8f3 100644 --- a/pkg/visor/visorconfig/services.go +++ b/pkg/visor/visorconfig/services.go @@ -52,13 +52,13 @@ func Fetch(mLog *logging.MasterLogger, serviceConf string, stdout bool) (service return services } -// Wrapper struct for the outer JSON +// EnvServices is the struct for the outer JSON type EnvServices struct { Test json.RawMessage `json:"test"` Prod json.RawMessage `json:"prod"` } -// Services are subdomains and IP addresses of the skywire services +// Services is subdomains and IP addresses of the skywire services type Services struct { DmsgDiscovery string `json:"dmsg_discovery,omitempty"` TransportDiscovery string `json:"transport_discovery,omitempty"` diff --git a/pkg/visor/visorconfig/v1.go b/pkg/visor/visorconfig/v1.go index b74fd5bd7a..3f19d26fe2 100644 --- a/pkg/visor/visorconfig/v1.go +++ b/pkg/visor/visorconfig/v1.go @@ -290,13 +290,13 @@ func (v1 *V1) AddAppConfig(launch *launcher.AppLauncher, appName, binaryName str for { min := 10 max := 99 - randomNumber = rand.Intn(max-min+1) + min //nolint - if _, ok := busyPorts[routing.Port(randomNumber)]; !ok { + randomNumber = rand.Intn(max-min+1) + min //nolint + if _, ok := busyPorts[routing.Port(randomNumber)]; !ok { //nolint break } } - conf.Apps = append(conf.Apps, appserver.AppConfig{Name: appName, Binary: binaryName, Port: routing.Port(randomNumber)}) + conf.Apps = append(conf.Apps, appserver.AppConfig{Name: appName, Binary: binaryName, Port: routing.Port(randomNumber)}) //nolint launch.ResetConfig(launcher.AppLauncherConfig{ VisorPK: v1.PK,