diff --git a/common/environment/app.go b/common/environment/app.go index face9836f..03c97616a 100644 --- a/common/environment/app.go +++ b/common/environment/app.go @@ -1,20 +1,16 @@ package environment -import ( - "github.com/v2fly/v2ray-core/v5/features/extension/storage" -) - type AppEnvironmentCapabilitySet interface { BaseEnvironmentCapabilitySet SystemNetworkCapabilitySet InstanceNetworkCapabilitySet FileSystemCapabilitySet - PersistentStorage() storage.ScopedPersistentStorage - TransientStorage() storage.ScopedTransientStorage + PersistentStorageCapabilitySet + TransientStorageCapabilitySet } type AppEnvironment interface { AppEnvironmentCapabilitySet - NarrowScope(key []byte) (AppEnvironment, error) + NarrowScope(key string) (AppEnvironment, error) doNotImpl() } diff --git a/common/environment/base.go b/common/environment/base.go index bbc5474f2..b8bd6ab6b 100644 --- a/common/environment/base.go +++ b/common/environment/base.go @@ -3,6 +3,7 @@ package environment import ( "github.com/v2fly/v2ray-core/v5/common/environment/filesystemcap" "github.com/v2fly/v2ray-core/v5/common/log" + "github.com/v2fly/v2ray-core/v5/features/extension/storage" "github.com/v2fly/v2ray-core/v5/transport/internet" "github.com/v2fly/v2ray-core/v5/transport/internet/tagged" ) @@ -37,3 +38,10 @@ type LogCapabilitySet interface { type FileSystemCapabilitySet interface { filesystemcap.FileSystemCapabilitySet } + +type PersistentStorageCapabilitySet interface { + PersistentStorage() storage.ScopedPersistentStorage +} +type TransientStorageCapabilitySet interface { + TransientStorage() storage.ScopedTransientStorage +} diff --git a/common/environment/envctx/env.go b/common/environment/envctx/env.go index c9aa5ac41..66f34e905 100644 --- a/common/environment/envctx/env.go +++ b/common/environment/envctx/env.go @@ -2,10 +2,8 @@ package envctx import "context" -type environmentContextKey int - const ( - environmentKey environmentContextKey = iota + environmentKey string = "v2.environment" ) func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context { diff --git a/common/environment/proxy.go b/common/environment/proxy.go index 49b63f478..10fe13a30 100644 --- a/common/environment/proxy.go +++ b/common/environment/proxy.go @@ -1,18 +1,14 @@ package environment -import ( - "github.com/v2fly/v2ray-core/v5/features/extension/storage" -) - type ProxyEnvironmentCapabilitySet interface { BaseEnvironmentCapabilitySet InstanceNetworkCapabilitySet - TransientStorage() storage.ScopedTransientStorage + TransientStorageCapabilitySet } type ProxyEnvironment interface { ProxyEnvironmentCapabilitySet - NarrowScope(key []byte) (ProxyEnvironment, error) - NarrowScopeToTransport(key []byte) (TransportEnvironment, error) + NarrowScope(key string) (ProxyEnvironment, error) + NarrowScopeToTransport(key string) (TransportEnvironment, error) doNotImpl() } diff --git a/common/environment/transport.go b/common/environment/transport.go index 5df017c6b..17ca47d48 100644 --- a/common/environment/transport.go +++ b/common/environment/transport.go @@ -1,18 +1,14 @@ package environment -import ( - "github.com/v2fly/v2ray-core/v5/features/extension/storage" -) - type TransportEnvironmentCapacitySet interface { BaseEnvironmentCapabilitySet SystemNetworkCapabilitySet InstanceNetworkCapabilitySet - TransientStorage() storage.ScopedTransientStorage + TransientStorageCapabilitySet } type TransportEnvironment interface { TransportEnvironmentCapacitySet - NarrowScope(key []byte) (TransportEnvironment, error) + NarrowScope(key string) (TransportEnvironment, error) doNotImpl() }