mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-05-18 13:09:04 -04:00
remove context public interface
This commit is contained in:
parent
007a15bd79
commit
620d8f1fb5
@ -13,6 +13,8 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/features/outbound"
|
"github.com/v2fly/v2ray-core/v4/features/outbound"
|
||||||
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
|
"github.com/v2fly/v2ray-core/v4/proxy/freedom"
|
||||||
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
"github.com/v2fly/v2ray-core/v4/transport/internet"
|
||||||
|
|
||||||
|
_ "unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInterfaces(t *testing.T) {
|
func TestInterfaces(t *testing.T) {
|
||||||
@ -20,7 +22,8 @@ func TestInterfaces(t *testing.T) {
|
|||||||
_ = (outbound.Manager)(new(Manager))
|
_ = (outbound.Manager)(new(Manager))
|
||||||
}
|
}
|
||||||
|
|
||||||
const v2rayKey core.V2rayKey = 1
|
//go:linkname mustToContextForced github.com/v2fly/v2ray-core/v4.mustToContext
|
||||||
|
func mustToContextForced(ctx context.Context, v *core.Instance) context.Context
|
||||||
|
|
||||||
func TestOutboundWithoutStatCounter(t *testing.T) {
|
func TestOutboundWithoutStatCounter(t *testing.T) {
|
||||||
config := &core.Config{
|
config := &core.Config{
|
||||||
@ -38,7 +41,7 @@ func TestOutboundWithoutStatCounter(t *testing.T) {
|
|||||||
|
|
||||||
v, _ := core.New(config)
|
v, _ := core.New(config)
|
||||||
v.AddFeature((outbound.Manager)(new(Manager)))
|
v.AddFeature((outbound.Manager)(new(Manager)))
|
||||||
ctx := context.WithValue(context.Background(), v2rayKey, v)
|
ctx := mustToContextForced(context.Background(), v)
|
||||||
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
|
h, _ := NewHandler(ctx, &core.OutboundHandlerConfig{
|
||||||
Tag: "tag",
|
Tag: "tag",
|
||||||
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
ProxySettings: serial.ToTypedMessage(&freedom.Config{}),
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// V2rayKey is the key type of Instance in Context, exported for test.
|
// V2rayKey is the key type of Instance in Context, exported for test.
|
||||||
type V2rayKey int
|
type v2rayKeyType int
|
||||||
|
|
||||||
const v2rayKey V2rayKey = 1
|
const v2rayKey v2rayKeyType = 1
|
||||||
|
|
||||||
// FromContext returns an Instance from the given context, or nil if the context doesn't contain one.
|
// FromContext returns an Instance from the given context, or nil if the context doesn't contain one.
|
||||||
func FromContext(ctx context.Context) *Instance {
|
func FromContext(ctx context.Context) *Instance {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user