Skip to content

Commit

Permalink
fix: multi bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Esonhugh committed Nov 22, 2024
1 parent 5e5ad04 commit 7dea322
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/server/sessionmanager/bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cmd/server/terminal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package terminal

import (
"github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd"
_ "github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd/admin"
_ "github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd/ops"
log "github.com/sirupsen/logrus"
"strings"
)
Expand Down Expand Up @@ -63,6 +65,7 @@ func (app Application) ExecuteCommand(cmd string) {
tcmd.RootCmd.SetArgs(cmdSplited)
tcmd.RootCmd.SetOut(app.Spec.ConsoleLogBuffer)
tcmd.RootCmd.CompletionOptions.DisableDefaultCmd = true
tcmd.RootCmd.SilenceUsage = true
tcmd.RootCmd.DisableSuggestions = true
err := tcmd.RootCmd.Execute()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/server/terminal/tcmd/admin/clear.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ func init() {
var clearCmd = &cobra.Command{
Use: "clear",
Short: "Clear screen",
Run: func(cmd *cobra.Command, args []string) {

},
}
5 changes: 5 additions & 0 deletions cmd/server/terminal/tcmd/admin/exit.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package admin

import (
"github.com/esonhugh/proxyinbrowser/cmd/server/terminal/tcmd"
"github.com/spf13/cobra"
"os"
)

func init() {
tcmd.RootCmd.AddCommand(exitCmd)
}

var exitCmd = &cobra.Command{
Use: "exit",
Aliases: []string{"quit", "q"},
Expand Down
3 changes: 3 additions & 0 deletions cmd/server/terminal/tcmd/admin/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ var listCmd = &cobra.Command{
Short: "List all available sessions",
Run: func(cmd *cobra.Command, args []string) {
list := sessionmanager.WebsocketConnMap.List()
if len(list) == 0 {
tcmd.Opt.Log.Infof("no sessions found")
}
tcmd.Opt.Log.Infoln("\n======LIST======\n" + strings.Join(list, "\n") + "\n")
},
}
6 changes: 5 additions & 1 deletion cmd/server/terminal/tcmd/admin/uid.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var UidCmd = &cobra.Command{
Use: "uid",
Short: "Lookup current uid",
Run: func(cmd *cobra.Command, args []string) {
tcmd.Opt.Log.Infof("Current session id is %v ", tcmd.Opt.SessionId)
if tcmd.Opt.SessionId == "" || tcmd.Opt.Session == nil {
tcmd.Opt.Log.Infof("session id useless")
} else {
tcmd.Opt.Log.Infof("Current session id is %v ", tcmd.Opt.SessionId)
}
},
}
2 changes: 1 addition & 1 deletion cmd/server/terminal/tcmd/ops/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var port string

func init() {
relayCmd.PersistentFlags().StringVarP(&port, "port", "p", "9001", "Port to listen on")
tcmd.RootCmd.AddCommand(relayCmd)
tcmd.RootCmd.AddCommand(relayCmd, stopRelayCmd)
}

var relayCmd = &cobra.Command{
Expand Down

0 comments on commit 7dea322

Please sign in to comment.