You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/app/router/router_test.go

48 lines
1.2 KiB

8 years ago
package router_test
import (
8 years ago
"context"
"testing"
"v2ray.com/core/app"
"v2ray.com/core/app/dispatcher"
_ "v2ray.com/core/app/dispatcher/impl"
"v2ray.com/core/app/dns"
_ "v2ray.com/core/app/dns/server"
"v2ray.com/core/app/proxyman"
_ "v2ray.com/core/app/proxyman/outbound"
8 years ago
. "v2ray.com/core/app/router"
v2net "v2ray.com/core/common/net"
8 years ago
"v2ray.com/core/proxy"
"v2ray.com/core/testing/assert"
)
func TestSimpleRouter(t *testing.T) {
9 years ago
assert := assert.On(t)
config := &Config{
Rule: []*RoutingRule{
9 years ago
{
Tag: "test",
NetworkList: &v2net.NetworkList{
Network: []v2net.Network{v2net.Network_TCP},
},
},
},
}
space := app.NewSpace()
8 years ago
ctx := app.ContextWithSpace(context.Background(), space)
assert.Error(app.AddApplicationToSpace(ctx, new(dns.Config))).IsNil()
assert.Error(app.AddApplicationToSpace(ctx, new(dispatcher.Config))).IsNil()
assert.Error(app.AddApplicationToSpace(ctx, new(proxyman.OutboundConfig))).IsNil()
assert.Error(app.AddApplicationToSpace(ctx, config)).IsNil()
assert.Error(space.Initialize()).IsNil()
r := FromSpace(space)
8 years ago
tag, err := r.TakeDetour(&proxy.SessionInfo{Destination: v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80)})
assert.Error(err).IsNil()
9 years ago
assert.String(tag).Equals("test")
}