github.com/badrootd/celestia-core@v0.0.0-20240305091328-aa4207a4b25d/cmd/cometbft/commands/probe_upnp.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 cmtjson "github.com/badrootd/celestia-core/libs/json" 9 "github.com/badrootd/celestia-core/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 } 19 20 func probeUpnp(cmd *cobra.Command, args []string) error { 21 capabilities, err := upnp.Probe(logger) 22 if err != nil { 23 fmt.Println("Probe failed: ", err) 24 } else { 25 fmt.Println("Probe success!") 26 jsonBytes, err := cmtjson.Marshal(capabilities) 27 if err != nil { 28 return err 29 } 30 fmt.Println(string(jsonBytes)) 31 } 32 return nil 33 }