1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 10:15:23 +00:00
v2fly/v2ray_test.go

71 lines
1.6 KiB
Go
Raw Normal View History

2017-02-05 07:44:08 +00:00
package core_test
import (
"testing"
. "v2ray.com/core"
"v2ray.com/core/app/proxyman"
"v2ray.com/core/common/dice"
2017-08-29 12:32:54 +00:00
"v2ray.com/core/common/net"
2017-02-05 07:44:08 +00:00
"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"
2017-10-24 14:15:35 +00:00
. "v2ray.com/ext/assert"
2017-02-05 07:44:08 +00:00
)
func TestV2RayClose(t *testing.T) {
2017-10-24 14:15:35 +00:00
assert := With(t)
2017-02-05 07:44:08 +00:00
2017-08-29 12:32:54 +00:00
port := net.Port(dice.RollUint16())
2018-01-18 22:25:48 +00:00
userId := uuid.New()
2017-02-05 07:44:08 +00:00
config := &Config{
2018-01-10 11:59:45 +00:00
App: []*serial.TypedMessage{
serial.ToTypedMessage(&proxyman.InboundConfig{}),
serial.ToTypedMessage(&proxyman.OutboundConfig{}),
},
Inbound: []*InboundHandlerConfig{
2017-02-05 07:44:08 +00:00
{
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
2017-08-29 12:32:54 +00:00
PortRange: net.SinglePortRange(port),
Listen: net.NewIPOrDomain(net.LocalHostIP),
2017-02-05 07:44:08 +00:00
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
2017-08-29 12:32:54 +00:00
Address: net.NewIPOrDomain(net.LocalHostIP),
2017-02-05 07:44:08 +00:00
Port: uint32(0),
2017-08-29 12:32:54 +00:00
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP, net.Network_UDP},
2017-02-05 07:44:08 +00:00
},
}),
},
},
2018-01-10 11:59:45 +00:00
Outbound: []*OutboundHandlerConfig{
2017-02-05 07:44:08 +00:00
{
ProxySettings: serial.ToTypedMessage(&outbound.Config{
Receiver: []*protocol.ServerEndpoint{
{
2017-08-29 12:32:54 +00:00
Address: net.NewIPOrDomain(net.LocalHostIP),
2017-02-05 07:44:08 +00:00
Port: uint32(0),
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
2018-01-18 22:25:48 +00:00
Id: userId.String(),
2017-02-05 07:44:08 +00:00
}),
},
},
},
},
}),
},
},
}
2017-02-10 15:25:54 +00:00
server, err := New(config)
2017-10-24 14:15:35 +00:00
assert(err, IsNil)
2017-02-05 07:44:08 +00:00
2017-02-10 15:25:54 +00:00
server.Close()
2017-02-05 07:44:08 +00:00
}