Skip to content

Commit

Permalink
skywire-cli vpn subcommands + separate-systray (#1317)
Browse files Browse the repository at this point in the history
* add flags for skywire-cli vpn list

* remove accidentally included files

* establish transport before starting VPN

* update vpn list cli command logic

* add skywire-cli vpn stop after successful tests with skywire-cli vpn start ; fix make check errors

* improve detection of vpn-client app config in api with range loop instead of hardcoding index ; make format check

* remove extra logging from cmd/skywire-visor/commands/root.go

* make separate-systray work with vpn cli commands

* update cmd/skywire-cli/commands/vpn/vvpn.go

* add version flag for skywire-cli ; filter results of skywire-cli vpn list by buildinfo.Version() instead of hardcoded version by default

* update cmd/skywire-systray/skywire-systray.go to match restructured skywire-cli subcommands

* make format check

* skywire-cli visor vpn list query filtering

* comment out query filtering ; make format check
  • Loading branch information
0pcom authored Aug 14, 2022
1 parent 8fe710c commit 9961f74
Show file tree
Hide file tree
Showing 29 changed files with 903 additions and 311 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package clihv
package clidmsgpty

import (
"fmt"
Expand All @@ -11,9 +11,7 @@ import (
)

func init() {
RootCmd.AddCommand(dmsgCmd)
dmsgCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address")
dmsgCmd.AddCommand(
RootCmd.AddCommand(
dmsgUICmd,
dmsgURLCmd,
)
Expand All @@ -25,11 +23,6 @@ func init() {
dmsgURLCmd.Flags().StringVarP(&pk, "visor", "v", "", "public key of visor to connect to")
}

var dmsgCmd = &cobra.Command{
Use: "dmsg",
Short: "DMSGPTY UI",
}

var dmsgUICmd = &cobra.Command{
Use: "ui",
Short: "Open dmsgpty UI in default browser",
Expand Down
22 changes: 15 additions & 7 deletions cmd/skywire-cli/commands/dmsgpty/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ import (
"github.com/skycoin/skywire/pkg/visor"
)

var rpcAddr string
var ptyPort string
var masterLogger = logging.NewMasterLogger()
var packageLogger = masterLogger.PackageLogger("dmsgpty")
var (
ptyPort string
masterLogger = logging.NewMasterLogger()
packageLogger = masterLogger.PackageLogger("dmsgpty")
logger = logging.MustGetLogger("skywire-cli")
rpcAddr string
path string
pk string
url string
pkg bool
)

func init() {
RootCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address")
RootCmd.PersistentFlags().StringVarP(&ptyPort, "port", "p", "22", "port of remote visor dmsgpty")
visorsCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address")
shellCmd.PersistentFlags().StringVarP(&rpcAddr, "rpc", "", "localhost:3435", "RPC server address")
shellCmd.PersistentFlags().StringVarP(&ptyPort, "port", "p", "22", "port of remote visor dmsgpty")
}

// RootCmd is the command that contains sub-commands which interacts with dmsgpty.
Expand Down Expand Up @@ -61,7 +69,7 @@ var visorsCmd = &cobra.Command{

var shellCmd = &cobra.Command{
Use: "start <pk>",
Short: "Start dmsgpty for specific visor by its dmsg address pk:port",
Short: "Start dmsgpty session",
Args: cobra.MinimumNArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
cli := dmsgpty.DefaultCLI()
Expand Down
43 changes: 0 additions & 43 deletions cmd/skywire-cli/commands/hv/hvpk.go

This file was deleted.

24 changes: 0 additions & 24 deletions cmd/skywire-cli/commands/hv/hvskychat.go

This file was deleted.

21 changes: 0 additions & 21 deletions cmd/skywire-cli/commands/hv/hvui.go

This file was deleted.

97 changes: 0 additions & 97 deletions cmd/skywire-cli/commands/hv/hvvpn.go

This file was deleted.

38 changes: 0 additions & 38 deletions cmd/skywire-cli/commands/hv/root.go

This file was deleted.

3 changes: 3 additions & 0 deletions cmd/skywire-cli/commands/mdisc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var packageLogger = masterLogger.PackageLogger("mdisc:disc")

func init() {
RootCmd.PersistentFlags().StringVar(&mdAddr, "addr", utilenv.DmsgDiscAddr, "address of DMSG discovery server\n")
var helpflag bool
RootCmd.Flags().BoolVarP(&helpflag, "help", "h", false, "help for "+RootCmd.Use)
RootCmd.Flags().MarkHidden("help") //nolint
}

// RootCmd is the command that contains sub-commands which interacts with DMSG services.
Expand Down
12 changes: 10 additions & 2 deletions cmd/skywire-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"

"github.com/skycoin/skywire-utilities/pkg/buildinfo"
clicompletion "github.com/skycoin/skywire/cmd/skywire-cli/commands/completion"
cliconfig "github.com/skycoin/skywire/cmd/skywire-cli/commands/config"
clidmsgpty "github.com/skycoin/skywire/cmd/skywire-cli/commands/dmsgpty"
clihv "github.com/skycoin/skywire/cmd/skywire-cli/commands/hv"
climdisc "github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc"
clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc"
clirtfind "github.com/skycoin/skywire/cmd/skywire-cli/commands/rtfind"
clivisor "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor"
clivpn "github.com/skycoin/skywire/cmd/skywire-cli/commands/vpn"
)

var rootCmd = &cobra.Command{
Expand All @@ -25,18 +27,24 @@ var rootCmd = &cobra.Command{
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Version: buildinfo.Version(),
}

func init() {
rootCmd.AddCommand(
cliconfig.RootCmd,
clidmsgpty.RootCmd,
clivisor.RootCmd,
clihv.RootCmd,
clivpn.RootCmd,
clirtfind.RootCmd,
climdisc.RootCmd,
clicompletion.RootCmd,
)
var helpflag bool
rootCmd.PersistentFlags().StringVarP(&clirpc.Addr, "rpc", "", "localhost:3435", "RPC server address")
rootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for "+rootCmd.Use)
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
rootCmd.PersistentFlags().MarkHidden("help") //nolint
}

// Execute executes root CLI command.
Expand Down
25 changes: 25 additions & 0 deletions cmd/skywire-cli/commands/rpc/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package clirpc

import (
"net"
"time"

"github.com/skycoin/skywire-utilities/pkg/logging"
"github.com/skycoin/skywire/pkg/visor"
)

var (
logger = logging.MustGetLogger("skywire-cli")
//Addr is the address (ip:port) of the rpc server
Addr string
)

// Client is used by other skywire-cli commands to query the visor rpc
func Client() visor.API {
const rpcDialTimeout = time.Second * 5
conn, err := net.DialTimeout("tcp", Addr, rpcDialTimeout)
if err != nil {
logger.Fatal("RPC connection failed; is skywire running?\n", err)
}
return visor.NewRPCClient(logger, conn, visor.RPCPrefix, 0)
}
3 changes: 3 additions & 0 deletions cmd/skywire-cli/commands/rtfind/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func init() {
RootCmd.Flags().Uint16VarP(&frMinHops, "min-hops", "n", 1, "minimum hops")
RootCmd.Flags().Uint16VarP(&frMaxHops, "max-hops", "x", 1000, "maximum hops")
RootCmd.Flags().DurationVarP(&timeout, "timeout", "t", 10*time.Second, "request timeout")
var helpflag bool
RootCmd.Flags().BoolVarP(&helpflag, "help", "h", false, "help for "+RootCmd.Use)
RootCmd.Flags().MarkHidden("help") //nolint
}

// RootCmd is the command that queries the route finder.
Expand Down
Loading

0 comments on commit 9961f74

Please sign in to comment.