Skip to content

Commit 7dea322

Browse files
committed
fix: multi bug
1 parent 5e5ad04 commit 7dea322

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

cmd/server/sessionmanager/bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/server/terminal/command.go

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package terminal
22

33
import (
44
"github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd"
5+
_ "github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd/admin"
6+
_ "github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd/ops"
57
log "github.com/sirupsen/logrus"
68
"strings"
79
)
@@ -63,6 +65,7 @@ func (app Application) ExecuteCommand(cmd string) {
6365
tcmd.RootCmd.SetArgs(cmdSplited)
6466
tcmd.RootCmd.SetOut(app.Spec.ConsoleLogBuffer)
6567
tcmd.RootCmd.CompletionOptions.DisableDefaultCmd = true
68+
tcmd.RootCmd.SilenceUsage = true
6669
tcmd.RootCmd.DisableSuggestions = true
6770
err := tcmd.RootCmd.Execute()
6871
if err != nil {

cmd/server/terminal/tcmd/admin/clear.go

+3
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ func init() {
1212
var clearCmd = &cobra.Command{
1313
Use: "clear",
1414
Short: "Clear screen",
15+
Run: func(cmd *cobra.Command, args []string) {
16+
17+
},
1518
}

cmd/server/terminal/tcmd/admin/exit.go

+5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package admin
22

33
import (
4+
"github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd"
45
"github.com/spf13/cobra"
56
"os"
67
)
78

9+
func init() {
10+
tcmd.RootCmd.AddCommand(exitCmd)
11+
}
12+
813
var exitCmd = &cobra.Command{
914
Use: "exit",
1015
Aliases: []string{"quit", "q"},

cmd/server/terminal/tcmd/admin/list.go

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var listCmd = &cobra.Command{
1717
Short: "List all available sessions",
1818
Run: func(cmd *cobra.Command, args []string) {
1919
list := sessionmanager.WebsocketConnMap.List()
20+
if len(list) == 0 {
21+
tcmd.Opt.Log.Infof("no sessions found")
22+
}
2023
tcmd.Opt.Log.Infoln("\n======LIST======\n" + strings.Join(list, "\n") + "\n")
2124
},
2225
}

cmd/server/terminal/tcmd/admin/uid.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ var UidCmd = &cobra.Command{
1313
Use: "uid",
1414
Short: "Lookup current uid",
1515
Run: func(cmd *cobra.Command, args []string) {
16-
tcmd.Opt.Log.Infof("Current session id is %v ", tcmd.Opt.SessionId)
16+
if tcmd.Opt.SessionId == "" || tcmd.Opt.Session == nil {
17+
tcmd.Opt.Log.Infof("session id useless")
18+
} else {
19+
tcmd.Opt.Log.Infof("Current session id is %v ", tcmd.Opt.SessionId)
20+
}
1721
},
1822
}

cmd/server/terminal/tcmd/ops/relay.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var port string
1010

1111
func init() {
1212
relayCmd.PersistentFlags().StringVarP(&port, "port", "p", "9001", "Port to listen on")
13-
tcmd.RootCmd.AddCommand(relayCmd)
13+
tcmd.RootCmd.AddCommand(relayCmd, stopRelayCmd)
1414
}
1515

1616
var relayCmd = &cobra.Command{

0 commit comments

Comments
 (0)