Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skywire-cli vpn subcommands + separate-systray #1317

Merged
merged 16 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these variables seem unsued.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package may as well just be called rpc in my opinion and function could be called Client() This would make obsolete to use RPC as prefix for variables as well.


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