mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-07 14:25:26 -04:00
context'ize apps
This commit is contained in:
@@ -40,13 +40,11 @@ func TestDokodemoTCP(t *testing.T) {
|
||||
defer tcpServer.Close()
|
||||
|
||||
space := app.NewSpace()
|
||||
space.AddApp(new(dispatcher.Config))
|
||||
space.AddApp(new(proxyman.OutboundConfig))
|
||||
ctx := app.ContextWithSpace(context.Background(), space)
|
||||
app.AddApplicationToSpace(ctx, new(dispatcher.Config))
|
||||
app.AddApplicationToSpace(ctx, new(proxyman.OutboundConfig))
|
||||
|
||||
ohm := proxyman.OutboundHandlerManagerFromSpace(space)
|
||||
ctx := context.Background()
|
||||
ctx = app.ContextWithSpace(ctx, space)
|
||||
|
||||
freedom, err := freedom.New(proxy.ContextWithOutboundMeta(ctx, &proxy.OutboundHandlerMeta{
|
||||
Address: v2net.LocalHostIP,
|
||||
StreamSettings: &internet.StreamConfig{
|
||||
@@ -117,13 +115,11 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
defer udpServer.Close()
|
||||
|
||||
space := app.NewSpace()
|
||||
space.AddApp(new(dispatcher.Config))
|
||||
space.AddApp(new(proxyman.OutboundConfig))
|
||||
ctx := app.ContextWithSpace(context.Background(), space)
|
||||
app.AddApplicationToSpace(ctx, new(dispatcher.Config))
|
||||
app.AddApplicationToSpace(ctx, new(proxyman.OutboundConfig))
|
||||
|
||||
ohm := proxyman.OutboundHandlerManagerFromSpace(space)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = app.ContextWithSpace(ctx, space)
|
||||
freedom, err := freedom.New(proxy.ContextWithOutboundMeta(ctx, &proxy.OutboundHandlerMeta{
|
||||
Address: v2net.AnyIP,
|
||||
StreamSettings: &internet.StreamConfig{
|
||||
|
||||
@@ -70,16 +70,16 @@ func TestIPResolution(t *testing.T) {
|
||||
assert := assert.On(t)
|
||||
|
||||
space := app.NewSpace()
|
||||
assert.Error(space.AddApp(new(proxyman.OutboundConfig))).IsNil()
|
||||
assert.Error(space.AddApp(new(dispatcher.Config))).IsNil()
|
||||
assert.Error(space.AddApp(new(router.Config))).IsNil()
|
||||
assert.Error(space.AddApp(&dns.Config{
|
||||
ctx := app.ContextWithSpace(context.Background(), space)
|
||||
assert.Error(app.AddApplicationToSpace(ctx, new(proxyman.OutboundConfig))).IsNil()
|
||||
assert.Error(app.AddApplicationToSpace(ctx, new(dispatcher.Config))).IsNil()
|
||||
assert.Error(app.AddApplicationToSpace(ctx, new(router.Config))).IsNil()
|
||||
assert.Error(app.AddApplicationToSpace(ctx, &dns.Config{
|
||||
Hosts: map[string]*v2net.IPOrDomain{
|
||||
"v2ray.com": v2net.NewIPOrDomain(v2net.LocalHostIP),
|
||||
},
|
||||
})).IsNil()
|
||||
|
||||
ctx := app.ContextWithSpace(context.Background(), space)
|
||||
ctx = proxy.ContextWithOutboundMeta(ctx, &proxy.OutboundHandlerMeta{
|
||||
Address: v2net.AnyIP,
|
||||
StreamSettings: &internet.StreamConfig{
|
||||
|
||||
Reference in New Issue
Block a user