mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-02 23:35:40 -05:00
move session based info into session package
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common/session"
|
||||
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
"v2ray.com/core/app/dispatcher"
|
||||
. "v2ray.com/core/app/router"
|
||||
@@ -17,11 +19,14 @@ import (
|
||||
"v2ray.com/core/common/platform"
|
||||
"v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/common/protocol/http"
|
||||
"v2ray.com/core/proxy"
|
||||
. "v2ray.com/ext/assert"
|
||||
"v2ray.com/ext/sysio"
|
||||
)
|
||||
|
||||
func withOutbound(outbound *session.Outbound) context.Context {
|
||||
return session.ContextWithOutbound(context.Background(), outbound)
|
||||
}
|
||||
|
||||
func TestRoutingRule(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
@@ -53,27 +58,27 @@ func TestRoutingRule(t *testing.T) {
|
||||
},
|
||||
test: []ruleTest{
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("v2ray.com"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("www.v2ray.com.www"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("www.v2ray.com.www"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("v2ray.co"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.co"), 80)}),
|
||||
output: false,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("www.google.com"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("www.google.com"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("facebook.com"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("facebook.com"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.DomainAddress("www.facebook.com"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.DomainAddress("www.facebook.com"), 80)}),
|
||||
output: false,
|
||||
},
|
||||
{
|
||||
@@ -101,15 +106,15 @@ func TestRoutingRule(t *testing.T) {
|
||||
},
|
||||
test: []ruleTest{
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.ParseAddress("8.8.8.8"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("8.8.8.8"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.ParseAddress("8.8.4.4"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("8.8.4.4"), 80)}),
|
||||
output: false,
|
||||
},
|
||||
{
|
||||
input: proxy.ContextWithTarget(context.Background(), net.TCPDestination(net.ParseAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), 80)),
|
||||
input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), 80)}),
|
||||
output: true,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user