mirror of
https://github.com/jixishi/SerialTerminalForWindowsTerminal.git
synced 2026-06-16 00:52:44 +00:00
refactor: extract pkg/forward and pkg/luaplugin packages
Move ForwardManager → pkg/forward/Manager and PluginManager → pkg/luaplugin/Manager. Move FoeWardMode (now forward.Mode) with ParseMode/Network/String into pkg/forward. Rename constants: NOT→None, TCPC→TCP, UDPC→UDP. Update all references in main package. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -27,49 +26,8 @@ type Config struct {
|
||||
hotkeyMod string
|
||||
}
|
||||
|
||||
type FoeWardMode int
|
||||
|
||||
const (
|
||||
NOT FoeWardMode = iota
|
||||
TCPC
|
||||
UDPC
|
||||
)
|
||||
|
||||
var config Config
|
||||
|
||||
func (m FoeWardMode) Network() string {
|
||||
switch m {
|
||||
case TCPC:
|
||||
return "tcp"
|
||||
case UDPC:
|
||||
return "udp"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (m FoeWardMode) String() string {
|
||||
switch m {
|
||||
case TCPC:
|
||||
return "tcp"
|
||||
case UDPC:
|
||||
return "udp"
|
||||
default:
|
||||
return "none"
|
||||
}
|
||||
}
|
||||
|
||||
func parseForwardMode(v string) (FoeWardMode, bool) {
|
||||
switch strings.ToLower(strings.TrimSpace(v)) {
|
||||
case "tcp", "tcp-c", "tcpc", "1":
|
||||
return TCPC, true
|
||||
case "udp", "udp-c", "udpc", "2":
|
||||
return UDPC, true
|
||||
default:
|
||||
return NOT, false
|
||||
}
|
||||
}
|
||||
|
||||
func openLogFile() (*os.File, error) {
|
||||
if config.enableLog {
|
||||
path := fmt.Sprintf(config.logFilePath, config.portName, time.Now().Format("2006_01_02T150405"))
|
||||
|
||||
Reference in New Issue
Block a user