1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-16 09:26:21 -05:00
v2fly/infra/conf/vless_test.go

131 lines
2.5 KiB
Go
Raw Normal View History

2020-07-28 11:00:23 -04:00
package conf_test
import (
"testing"
2021-02-16 15:31:50 -05:00
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/protocol"
"github.com/v2fly/v2ray-core/v4/common/serial"
. "github.com/v2fly/v2ray-core/v4/infra/conf"
"github.com/v2fly/v2ray-core/v4/proxy/vless"
"github.com/v2fly/v2ray-core/v4/proxy/vless/inbound"
"github.com/v2fly/v2ray-core/v4/proxy/vless/outbound"
2020-07-28 11:00:23 -04:00
)
func TestVLessOutbound(t *testing.T) {
creator := func() Buildable {
return new(VLessOutboundConfig)
}
runMultiTestCase(t, []TestCase{
{
Input: `{
"vnext": [{
"address": "example.com",
"port": 443,
"users": [
{
"id": "27848739-7e62-4138-9fd3-098a63964b6b",
"encryption": "none",
"level": 0
}
]
}]
}`,
Parser: loadJSON(creator),
Output: &outbound.Config{
2020-08-28 03:51:09 -04:00
Vnext: []*protocol.ServerEndpoint{
2020-07-28 11:00:23 -04:00
{
Address: &net.IPOrDomain{
Address: &net.IPOrDomain_Domain{
Domain: "example.com",
},
},
Port: 443,
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vless.Account{
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
Encryption: "none",
}),
Level: 0,
},
},
},
},
},
},
})
}
func TestVLessInbound(t *testing.T) {
creator := func() Buildable {
return new(VLessInboundConfig)
}
runMultiTestCase(t, []TestCase{
{
Input: `{
"clients": [
{
"id": "27848739-7e62-4138-9fd3-098a63964b6b",
"level": 0,
"email": "love@v2fly.org"
}
],
"decryption": "none",
2020-08-28 03:51:09 -04:00
"fallbacks": [
{
"dest": 80
},
{
"alpn": "h2",
"dest": "@/dev/shm/domain.socket",
"xver": 2
},
{
"path": "/innerws",
"dest": "serve-ws-none"
}
]
2020-07-28 11:00:23 -04:00
}`,
Parser: loadJSON(creator),
Output: &inbound.Config{
2020-08-28 03:51:09 -04:00
Clients: []*protocol.User{
2020-07-28 11:00:23 -04:00
{
Account: serial.ToTypedMessage(&vless.Account{
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
2020-07-28 11:00:23 -04:00
}),
Level: 0,
Email: "love@v2fly.org",
},
},
Decryption: "none",
2020-08-28 03:51:09 -04:00
Fallbacks: []*inbound.Fallback{
{
Alpn: "",
Path: "",
Type: "tcp",
Dest: "127.0.0.1:80",
Xver: 0,
2020-07-28 11:00:23 -04:00
},
2020-08-28 03:51:09 -04:00
{
Alpn: "h2",
Path: "",
Type: "unix",
2020-09-07 04:39:53 -04:00
Dest: "@/dev/shm/domain.socket",
2020-08-28 03:51:09 -04:00
Xver: 2,
},
{
Alpn: "",
Path: "/innerws",
Type: "serve",
Dest: "serve-ws-none",
Xver: 0,
2020-08-03 02:13:26 -04:00
},
2020-07-28 11:00:23 -04:00
},
},
},
})
}