From bb18a9e3d1e186f9dcd60c1bc4f4606edd865a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Tue, 24 Mar 2026 17:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependencies.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/application/frpc/service.go | 42 ++++++++++++---------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/internal/application/frpc/service.go b/internal/application/frpc/service.go index 76cb4f9..cdb7a46 100644 --- a/internal/application/frpc/service.go +++ b/internal/application/frpc/service.go @@ -21,6 +21,7 @@ import ( "podux/pkg/utils" "github.com/fatedier/frp/client" + frpcsource "github.com/fatedier/frp/pkg/config/source" v1 "github.com/fatedier/frp/pkg/config/v1" "github.com/fatedier/frp/pkg/util/log" "github.com/pocketbase/pocketbase/core" @@ -235,10 +236,6 @@ func (fs *Service) LaunchFrpc(serverId *string) error { fs.app.Logger().Debug("Config", "serverAddr", cfg.ServerAddr, "serverPort", cfg.ServerPort, "proxyCount", len(proxyCfgs)) - for _, c := range proxyCfgs { - c.Complete(cfg.User) - } - // Print frp configurations in logs with sensitive data masked commonCfgBytes, _ := json.Marshal(cfg) proxyCfgsBytes, _ := json.Marshal(proxyCfgs) @@ -251,9 +248,13 @@ func (fs *Service) LaunchFrpc(serverId *string) error { cfg.Complete() log.InitLogger(cfg.Log.To, cfg.Log.Level, int(cfg.Log.MaxDays), cfg.Log.DisablePrintColor) + configSrc := frpcsource.NewConfigSource() + if err := configSrc.ReplaceAll(proxyCfgs, nil); err != nil { + return err + } svr, err := client.NewService(client.ServiceOptions{ - Common: cfg, - ProxyCfgs: proxyCfgs, + Common: cfg, + ConfigSourceAggregator: frpcsource.NewAggregator(configSrc), }) if err != nil { fs.app.Logger().Error("NewService", "err", err) @@ -284,13 +285,13 @@ func (fs *Service) LaunchFrpc(serverId *string) error { done <- err }() - go fs.monitorServiceStatus(serverId, svr, ctx, done, cfg.User) + go fs.monitorServiceStatus(serverId, svr, ctx, done) return nil } // monitorServiceStatus monitors service status and updates the database. -func (fs *Service) monitorServiceStatus(id *string, svr *client.Service, ctx context.Context, done <-chan error, user string) { +func (fs *Service) monitorServiceStatus(id *string, svr *client.Service, ctx context.Context, done <-chan error) { time.Sleep(2 * time.Second) select { @@ -307,7 +308,7 @@ func (fs *Service) monitorServiceStatus(id *string, svr *client.Service, ctx con fs.app.Logger().Info("Service is running", "id", *id) } - go fs.monitorProxyStatus(id, svr, ctx, user) + go fs.monitorProxyStatus(id, svr, ctx) ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() @@ -342,7 +343,7 @@ func (fs *Service) destroying(id *string) { } // monitorProxyStatus monitors proxy status from frp and updates the database. -func (fs *Service) monitorProxyStatus(serverId *string, svr *client.Service, ctx context.Context, user string) { +func (fs *Service) monitorProxyStatus(serverId *string, svr *client.Service, ctx context.Context) { fs.app.Logger().Info("Starting proxy status monitoring", "serverId", *serverId) statusExporter := svr.StatusExporter() @@ -364,11 +365,13 @@ func (fs *Service) monitorProxyStatus(serverId *string, svr *client.Service, ctx for _, proxy := range proxies { baseName := proxy.Name + "-" + proxy.Id - prefix := "" - if user != "" { - prefix = user + "." - } - status, exists := statusExporter.GetProxyStatus(prefix + baseName) + status, exists := statusExporter.GetProxyStatus(baseName) + fs.app.Logger().Info("proxy status check", "baseName", baseName, "exists", exists, "phase", func() string { + if status != nil { + return status.Phase + } + return "nil" + }()) if exists { var bootStatus proxydomain.ProxyBootStatus @@ -493,15 +496,6 @@ func (fs *Service) ReloadFrpc(serverId *string) error { return err } - server, err := fs.app.FindRecordById("fh_servers", *serverId) - if err != nil { - return err - } - user := server.GetString("user") - for _, c := range proxyCfgs { - c.Complete(user) - } - proxyCfgsBytes, _ := json.Marshal(proxyCfgs) safeProxies := sensitiveRegex.ReplaceAll(proxyCfgsBytes, []byte(`"${1}":"***"`)) fs.app.Logger().Info("FRP Reload Configurations", "proxies", string(safeProxies))