Skip to content

Commit

Permalink
Add new function & Update README, close #29
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4ntonn committed Dec 6, 2024
1 parent 9b53c6c commit 57deccf
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 6 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ Node[1]'s children ->
```
(node 0) >> help
help Show help information
status Show node status,including socks/forward/backward
listen Start port listening on current node
addmemo <string> Add memo for current node
delmemo Delete memo of current node
Expand All @@ -457,6 +458,20 @@ Node[1]'s children ->
back Back to parent panel
exit Exit Stowaway
```
- `status`: 展示当前节点的socks/forward/backward状态

```
(node 0) >> status
Socks status:
ListenAddr: 0.0.0.0:10000 Username: Password:
-------------------------------------------------------------------------------------------
Forward status:
[1] Listening Addr: [::]:20000 , Remote Addr: 192.168.1.1:22 , Active Connnections: 0
[2] Listening Addr: [::]:30000 , Remote Addr: 192.168.1.1:22 , Active Connnections: 0
-------------------------------------------------------------------------------------------
Backward status:
[1] Remote Port: 40000 , Local Port: 50000 , Active Connnections: 0
```

- `listen`: 命令agent监听某个端口并等待子节点的连入

Expand Down Expand Up @@ -641,7 +656,7 @@ $
```
(node 0) >> stopforward
[0] All
[1] Listening Addr : [::]:9000 , Remote Addr : 127.0.0.1:22 , Current Active Connnections : 1
[1] Listening Addr : [::]:9000 , Remote Addr : 127.0.0.1:22 , Active Connnections : 1
[*] Do you really want to shutdown forward?(yes/no): yes
[*] Please choose one to close: 1
[*] Closing......
Expand Down Expand Up @@ -670,7 +685,7 @@ $
```
(node 0) >> stopbackward
[0] All
[1] Remote Port : 9001 , Local Port : 22 , Current Active Connnections : 1
[1] Remote Port : 9001 , Local Port : 22 , Active Connnections : 1
[*] Do you really want to shutdown backward?(yes/no): yes
[*] Please choose one to close: 1
[*] Closing......
Expand Down
20 changes: 18 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ When user selects an node via `use` command, admin will enter the second level:
```
(node 0) >> help
help Show help information
status Show node status,including socks/forward/backward
listen Start port listening on current node
addmemo <string> Add memo for current node
delmemo Delete memo of current node
Expand All @@ -446,6 +447,21 @@ When user selects an node via `use` command, admin will enter the second level:
exit Exit Stowaway
```

- `status`: Display the socks/forward/backward status of the current node

```
(node 0) >> status
Socks status:
ListenAddr: 0.0.0.0:10000 Username: Password:
-------------------------------------------------------------------------------------------
Forward status:
[1] Listening Addr: [::]:20000 , Remote Addr: 192.168.1.1:22 , Active Connnections: 0
[2] Listening Addr: [::]:30000 , Remote Addr: 192.168.1.1:22 , Active Connnections: 0
-------------------------------------------------------------------------------------------
Backward status:
[1] Remote Port: 40000 , Local Port: 50000 , Active Connnections: 0
```

- `listen`: Instruct the node to listen on a specific port and wait for connection from child node

```
Expand Down Expand Up @@ -629,7 +645,7 @@ $
```
(node 0) >> stopforward
[0] All
[1] Listening Addr : [::]:9000 , Remote Addr : 127.0.0.1:22 , Current Active Connnections : 1
[1] Listening Addr : [::]:9000 , Remote Addr : 127.0.0.1:22 , Active Connnections : 1
[*] Do you really want to shutdown forward?(yes/no): yes
[*] Please choose one to close: 1
[*] Closing......
Expand Down Expand Up @@ -658,7 +674,7 @@ $
```
(node 0) >> stopbackward
[0] All
[1] Remote Port : 9001 , Local Port : 22 , Current Active Connnections : 1
[1] Remote Port : 9001 , Local Port : 22 , Active Connnections : 1
[*] Do you really want to shutdown backward?(yes/no): yes
[*] Please choose one to close: 1
[*] Closing......
Expand Down
1 change: 1 addition & 0 deletions admin/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func ShowMainHelp() {
func ShowNodeHelp() {
fmt.Print(`
help Show help information
status Show node status,including socks/forward/backward
listen Start port listening on current node
addmemo <string> Add memo for current node
delmemo Delete memo of current node
Expand Down
1 change: 1 addition & 0 deletions admin/cli/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func NewHelper() *Helper {

helper.nodeList = []string{
"help",
"status",
"listen",
"addmemo",
"delmemo",
Expand Down
7 changes: 7 additions & 0 deletions admin/cli/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,13 @@ func (console *Console) handleNodePanelCommand(uuidNum int) {
fCommand := strings.Split(tCommand, " ")

switch fCommand[0] {
case "status":
if !console.isOnline(uuidNum) {
return
}

handler.ShowStatus(console.mgr, uuid)
console.ready <- true
case "addmemo":
if !console.isOnline(uuidNum) {
return
Expand Down
7 changes: 7 additions & 0 deletions admin/cli/interactive_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ func (console *Console) handleNodePanelCommand(uuidNum int) {
fCommand := strings.Split(tCommand, " ")

switch fCommand[0] {
case "status":
if !console.isOnline(uuidNum) {
return
}

handler.ShowStatus(console.mgr, uuid)
console.ready <- true
case "addmemo":
if !console.isOnline(uuidNum) {
return
Expand Down
2 changes: 1 addition & 1 deletion admin/handler/backward.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func GetBackwardInfo(mgr *manager.Manager, uuid string) (int, bool) {
fmt.Print("\r\n[0] All")
for _, info := range result.BackwardInfo {
fmt.Printf(
"\r\n[%d] Remote Port: %s , Local Port: %s , Current Active Connnections: %d",
"\r\n[%d] Remote Port: %s , Local Port: %s , Active Connnections: %d",
info.Seq,
info.RPort,
info.LPort,
Expand Down
2 changes: 1 addition & 1 deletion admin/handler/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func GetForwardInfo(mgr *manager.Manager, uuid string) (int, bool) {
fmt.Print("\r\n[0] All")
for _, info := range result.ForwardInfo {
fmt.Printf(
"\r\n[%d] Listening Addr: %s , Remote Addr: %s , Current Active Connnections: %d",
"\r\n[%d] Listening Addr: %s , Remote Addr: %s , Active Connnections: %d",
info.Seq,
info.Laddr,
info.Raddr,
Expand Down
File renamed without changes.
68 changes: 68 additions & 0 deletions admin/handler/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package handler

import (
"Stowaway/admin/manager"
"fmt"
)

func ShowStatus(mgr *manager.Manager, uuid string) {
forwardTask := &manager.ForwardTask{
Mode: manager.F_GETFORWARDINFO,
UUID: uuid,
}
mgr.ForwardManager.TaskChan <- forwardTask
forwardResult := <-mgr.ForwardManager.ResultChan

backwardTask := &manager.BackwardTask{
Mode: manager.B_GETBACKWARDINFO,
UUID: uuid,
}
mgr.BackwardManager.TaskChan <- backwardTask
backwardResult := <-mgr.BackwardManager.ResultChan

socksTask := &manager.SocksTask{
Mode: manager.S_GETSOCKSINFO,
UUID: uuid,
}
mgr.SocksManager.TaskChan <- socksTask
socksResult := <-mgr.SocksManager.ResultChan
// show socks
fmt.Print("\r\nSocks status:")
if socksResult.OK {
fmt.Printf(
"\r\n ListenAddr: %s:%s Username: %s Password: %s",
socksResult.SocksInfo.Addr,
socksResult.SocksInfo.Port,
socksResult.SocksInfo.Username,
socksResult.SocksInfo.Password,
)
}
fmt.Print("\r\n-------------------------------------------------------------------------------------------")
// show forward
fmt.Print("\r\nForward status:")
if forwardResult.OK {
for _, info := range forwardResult.ForwardInfo {
fmt.Printf(
"\r\n [%d] Listening Addr: %s , Remote Addr: %s , Active Connnections: %d",
info.Seq,
info.Laddr,
info.Raddr,
info.ActiveNum,
)
}
}
fmt.Print("\r\n-------------------------------------------------------------------------------------------")
// show backward
fmt.Print("\r\nBackward status:")
if backwardResult.OK {
for _, info := range backwardResult.BackwardInfo {
fmt.Printf(
"\r\n [%d] Remote Port: %s , Local Port: %s , Active Connnections: %d",
info.Seq,
info.RPort,
info.LPort,
info.ActiveNum,
)
}
}
}

0 comments on commit 57deccf

Please sign in to comment.