2017-02-05 02:44:08 -05:00
|
|
|
package core_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
. "v2ray.com/core"
|
|
|
|
"v2ray.com/core/app/proxyman"
|
|
|
|
"v2ray.com/core/common/dice"
|
2017-08-29 08:32:54 -04:00
|
|
|
"v2ray.com/core/common/net"
|
2017-02-05 02:44:08 -05: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"
|
|
|
|
"v2ray.com/core/testing/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestV2RayClose(t *testing.T) {
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
2017-08-29 08:32:54 -04:00
|
|
|
port := net.Port(dice.RollUint16())
|
2017-02-05 02:44:08 -05:00
|
|
|
config := &Config{
|
|
|
|
Inbound: []*proxyman.InboundHandlerConfig{
|
|
|
|
{
|
|
|
|
ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{
|
2017-08-29 08:32:54 -04:00
|
|
|
PortRange: net.SinglePortRange(port),
|
|
|
|
Listen: net.NewIPOrDomain(net.LocalHostIP),
|
2017-02-05 02:44:08 -05:00
|
|
|
}),
|
|
|
|
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
|
2017-08-29 08:32:54 -04:00
|
|
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
2017-02-05 02:44:08 -05:00
|
|
|
Port: uint32(0),
|
2017-08-29 08:32:54 -04:00
|
|
|
NetworkList: &net.NetworkList{
|
|
|
|
Network: []net.Network{net.Network_TCP, net.Network_UDP},
|
2017-02-05 02:44:08 -05:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Outbound: []*proxyman.OutboundHandlerConfig{
|
|
|
|
{
|
|
|
|
ProxySettings: serial.ToTypedMessage(&outbound.Config{
|
|
|
|
Receiver: []*protocol.ServerEndpoint{
|
|
|
|
{
|
2017-08-29 08:32:54 -04:00
|
|
|
Address: net.NewIPOrDomain(net.LocalHostIP),
|
2017-02-05 02:44:08 -05:00
|
|
|
Port: uint32(0),
|
|
|
|
User: []*protocol.User{
|
|
|
|
{
|
|
|
|
Account: serial.ToTypedMessage(&vmess.Account{
|
|
|
|
Id: uuid.New().String(),
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-02-10 10:25:54 -05:00
|
|
|
server, err := New(config)
|
2017-02-05 02:44:08 -05:00
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
2017-02-10 10:25:54 -05:00
|
|
|
server.Close()
|
2017-02-05 02:44:08 -05:00
|
|
|
}
|