leverage global object creator in proxies.

This commit is contained in:
Darien Raymond
2017-01-13 00:56:21 +01:00
parent db1c9131f0
commit 148e4832eb
23 changed files with 353 additions and 269 deletions
+6 -2
View File
@@ -1,6 +1,7 @@
package proxy_test
import (
"context"
"testing"
"v2ray.com/core/app"
@@ -21,14 +22,17 @@ func TestProxyDial(t *testing.T) {
assert := assert.On(t)
space := app.NewSpace()
ctx := app.ContextWithSpace(context.Background(), space)
assert.Error(space.AddApp(new(proxyman.OutboundConfig)))
outboundManager := proxyman.OutboundHandlerManagerFromSpace(space)
common.Must(outboundManager.SetHandler("tag", freedom.New(&freedom.Config{}, space, &proxy.OutboundHandlerMeta{
freedom, err := freedom.New(proxy.ContextWithOutboundMeta(ctx, &proxy.OutboundHandlerMeta{
Tag: "tag",
StreamSettings: &internet.StreamConfig{
Protocol: internet.TransportProtocol_TCP,
},
})))
}), &freedom.Config{})
assert.Error(err).IsNil()
common.Must(outboundManager.SetHandler("tag", freedom))
assert.Error(space.AddApp(new(Config))).IsNil()
proxy := OutboundProxyFromSpace(space)