github.com/Oyster-zx/tendermint@v0.34.24-fork/cmd/tendermint/commands/probe_upnp.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 tmjson "github.com/tendermint/tendermint/libs/json" 9 "github.com/tendermint/tendermint/p2p/upnp" 10 ) 11 12 // ProbeUpnpCmd adds capabilities to test the UPnP functionality. 13 var ProbeUpnpCmd = &cobra.Command{ 14 Use: "probe-upnp", 15 Aliases: []string{"probe_upnp"}, 16 Short: "Test UPnP functionality", 17 RunE: probeUpnp, 18 PreRun: deprecateSnakeCase, 19 } 20 21 func probeUpnp(cmd *cobra.Command, args []string) error { 22 capabilities, err := upnp.Probe(logger) 23 if err != nil { 24 fmt.Println("Probe failed: ", err) 25 } else { 26 fmt.Println("Probe success!") 27 jsonBytes, err := tmjson.Marshal(capabilities) 28 if err != nil { 29 return err 30 } 31 fmt.Println(string(jsonBytes)) 32 } 33 return nil 34 }