diff --git a/Dockerfile b/Dockerfile index 6f3d795..0a619e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build \ FROM alpine:latest # 先切换到国内镜像源,再安装包 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates tzdata sqlite +RUN apk --no-cache add ca-certificates tzdata sqlite bash WORKDIR /app diff --git a/internal/frp/frpc.tmpl b/internal/frp/frpc.tmpl index 910ff3f..65f5deb 100644 --- a/internal/frp/frpc.tmpl +++ b/internal/frp/frpc.tmpl @@ -20,7 +20,8 @@ poolCount = {{.PoolCount}} {{end}} [webServer] -addr = "127.0.0.1:{{.AdminPort}}" +addr = "127.0.0.1" +port = {{.AdminPort}} {{range .Proxies}} [[proxies]] diff --git a/internal/process/manager.go b/internal/process/manager.go index 4db4d2c..28f68c8 100644 --- a/internal/process/manager.go +++ b/internal/process/manager.go @@ -58,8 +58,8 @@ const ( PhaseDegraded ProcessPhase = "DEGRADED" PhaseFailed ProcessPhase = "FAILED" PhaseStopped ProcessPhase = "STOPPED" - PhaseStopping ProcessPhase = "STOPPING" // 正在停止中 - PhaseConflict ProcessPhase = "CONFLICT" // 检测到多实例冲突 + PhaseStopping ProcessPhase = "STOPPING" + PhaseConflict ProcessPhase = "CONFLICT" ) // ================================================================ @@ -76,7 +76,7 @@ type FrpcInstance struct { ParentPID int ExecPath string CmdLine string - Owned bool // 是否由当前 ProcessManager 管理 + Owned bool } type ProcessState struct { @@ -98,15 +98,10 @@ type ProcessState struct { LastError string `json:"last_error,omitempty"` Error string `json:"error,omitempty"` - // 冲突检测信息 Conflicts []FrpcInstance `json:"conflicts,omitempty"` } -var ( - globalManager *ProcessManager - globalMu sync.Mutex -) - +// PortStatus 兼容旧接口 type PortStatus struct { Port int `json:"port"` Occupied bool `json:"occupied"` @@ -115,6 +110,7 @@ type PortStatus struct { ProcessCmd string `json:"process_cmd,omitempty"` } +// FRPCStatus 来自 frpc admin API 的状态响应 type FRPCStatus struct { Version string `json:"version"` RunID string `json:"run_id"` @@ -126,6 +122,15 @@ type FRPCStatus struct { } `json:"proxies"` } +// ================================================================ +// 全局变量 +// ================================================================ + +var ( + globalManager *ProcessManager + globalMu sync.Mutex +) + // ================================================================ // ProcessManager 主结构 // ================================================================ @@ -149,12 +154,8 @@ type ProcessManager struct { lockFile *os.File locked bool - // 当前状态缓存 currentPhase ProcessPhase statusMu sync.RWMutex - - // 取消函数(用于停止健康检查) - cancelFunc context.CancelFunc } // ================================================================