From a65d3e040a11582c33f5255e5e05ead97f341b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 13 Aug 2025 11:26:05 +0800 Subject: [PATCH] platform: Fix context --- experimental/libbox/config.go | 5 ++++- experimental/libbox/service.go | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/experimental/libbox/config.go b/experimental/libbox/config.go index 7dc84b83..89c51222 100644 --- a/experimental/libbox/config.go +++ b/experimental/libbox/config.go @@ -22,6 +22,7 @@ import ( "github.com/sagernet/sing/common/logger" "github.com/sagernet/sing/common/x/list" "github.com/sagernet/sing/service" + "github.com/sagernet/sing/service/filemanager" ) func BaseContext(platformInterface PlatformInterface) context.Context { @@ -33,7 +34,9 @@ func BaseContext(platformInterface PlatformInterface) context.Context { }) } } - return box.Context(context.Background(), include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry(), dnsRegistry, include.ServiceRegistry()) + ctx := context.Background() + ctx = filemanager.WithDefault(ctx, sWorkingPath, sTempPath, sUserID, sGroupID) + return box.Context(ctx, include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry(), dnsRegistry, include.ServiceRegistry()) } func parseConfig(ctx context.Context, configContent string) (option.Options, error) { diff --git a/experimental/libbox/service.go b/experimental/libbox/service.go index 7f80e6fe..8c94b389 100644 --- a/experimental/libbox/service.go +++ b/experimental/libbox/service.go @@ -27,7 +27,6 @@ import ( "github.com/sagernet/sing/common/logger" N "github.com/sagernet/sing/common/network" "github.com/sagernet/sing/service" - "github.com/sagernet/sing/service/filemanager" "github.com/sagernet/sing/service/pause" ) @@ -44,7 +43,6 @@ type BoxService struct { func NewService(configContent string, platformInterface PlatformInterface) (*BoxService, error) { ctx := BaseContext(platformInterface) - ctx = filemanager.WithDefault(ctx, sWorkingPath, sTempPath, sUserID, sGroupID) service.MustRegister[deprecated.Manager](ctx, new(deprecatedManager)) options, err := parseConfig(ctx, configContent) if err != nil {