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/v2ray_test.go

74 lines
1.8 KiB

8 years ago
package core_test
import (
"testing"
proto "github.com/golang/protobuf/proto"
8 years ago
. "v2ray.com/core"
"v2ray.com/core/app/dispatcher"
8 years ago
"v2ray.com/core/app/proxyman"
"v2ray.com/core/common"
8 years ago
"v2ray.com/core/common/dice"
"v2ray.com/core/common/net"
8 years ago
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial"
"v2ray.com/core/common/uuid"
_ "v2ray.com/core/main/distro/all"
"v2ray.com/core/proxy/dokodemo"
"v2ray.com/core/proxy/vmess"
"v2ray.com/core/proxy/vmess/outbound"
)
func TestV2RayClose(t *testing.T) {
port := net.Port(dice.RollUint16())
userId := uuid.New()
8 years ago
config := &Config{
7 years ago
App: []*serial.TypedMessage{
serial.ToTypedMessage(&dispatcher.Config{}),
7 years ago
serial.ToTypedMessage(&proxyman.InboundConfig{}),
serial.ToTypedMessage(&proxyman.OutboundConfig{}),
},
Inbound: []*InboundHandlerConfig{
8 years ago
{
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
PortRange: net.SinglePortRange(port),
Listen: net.NewIPOrDomain(net.LocalHostIP),
8 years ago
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
Address: net.NewIPOrDomain(net.LocalHostIP),
8 years ago
Port: uint32(0),
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP, net.Network_UDP},
8 years ago
},
}),
},
},
7 years ago
Outbound: []*OutboundHandlerConfig{
8 years ago
{
ProxySettings: serial.ToTypedMessage(&outbound.Config{
Receiver: []*protocol.ServerEndpoint{
{
Address: net.NewIPOrDomain(net.LocalHostIP),
8 years ago
Port: uint32(0),
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userId.String(),
8 years ago
}),
},
},
},
},
}),
},
},
}
cfgBytes, err := proto.Marshal(config)
common.Must(err)
8 years ago
server, err := StartInstance("protobuf", cfgBytes)
common.Must(err)
8 years ago
server.Close()
8 years ago
}