mirror of
https://github.com/jixishi/SerialTerminalForWindowsTerminal.git
synced 2026-06-16 00:52:44 +00:00
feat: add TCP Server, UDP Server, and COM port forwarding modes
Extend Mode constants (3=TCPServer, 4=UDPServer, 5=COMPort) with explicit values. Refactor Target to support multiple connection types (listener+conns map, packetConn, serialPort). Add acceptLoop, readLoopPacket, readLoopSerial. Mode-aware Broadcast dispatches to all accepted conns (TCP-S), known remotes (UDP-S), or serial port. Update flag help, command completions, and TUI panel hints. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -39,7 +39,7 @@ func (d *Dispatcher) handleForwardCommand(args []string) error {
|
||||
|
||||
case "add":
|
||||
if len(args) < 4 {
|
||||
return fmt.Errorf("usage: .forward add <tcp|udp> <address>")
|
||||
return fmt.Errorf("usage: .forward add <tcp|udp|tcp-s|udp-s|com> <address>")
|
||||
}
|
||||
mode, ok := forward.ParseMode(args[2])
|
||||
if !ok {
|
||||
@@ -71,7 +71,7 @@ func (d *Dispatcher) handleForwardCommand(args []string) error {
|
||||
|
||||
case "update":
|
||||
if len(args) < 5 {
|
||||
return fmt.Errorf("usage: .forward update <id> <tcp|udp> <address>")
|
||||
return fmt.Errorf("usage: .forward update <id> <tcp|udp|tcp-s|udp-s|com> <address>")
|
||||
}
|
||||
id, err := strconv.Atoi(args[2])
|
||||
if err != nil {
|
||||
|
||||
@@ -29,15 +29,15 @@ func filterPrefix(cands []string, cur string) []string {
|
||||
|
||||
func completeForward(args []string) []string {
|
||||
if len(args) <= 2 {
|
||||
return []string{"list", "add", "remove", "enable", "disable", "update", "stats"}
|
||||
return []string{"list", "add", "remove", "enable", "disable", "update"}
|
||||
}
|
||||
|
||||
if len(args) == 3 && args[1] == "add" {
|
||||
return []string{"tcp", "udp"}
|
||||
return []string{"tcp", "udp", "tcp-s", "udp-s", "com"}
|
||||
}
|
||||
|
||||
if len(args) == 4 && args[1] == "update" {
|
||||
return []string{"tcp", "udp"}
|
||||
return []string{"tcp", "udp", "tcp-s", "udp-s", "com"}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -99,8 +99,8 @@ func (d *Dispatcher) registerAll() {
|
||||
|
||||
d.register(RuntimeCommand{
|
||||
Name: ".forward",
|
||||
Usage: ".forward <list|add|remove|enable|disable|update|stats>",
|
||||
Description: "manage forwarding at runtime",
|
||||
Usage: ".forward <list|add|remove|enable|disable|update>",
|
||||
Description: "manage forwarding (tcp/udp/tcp-s/udp-s/com)",
|
||||
Handler: d.handleForwardCommand,
|
||||
Completer: completeForward,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user