github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/infra/conf/vless_test.go (about) 1 package conf_test 2 3 import ( 4 "testing" 5 6 "v2ray.com/core/common/net" 7 "v2ray.com/core/common/protocol" 8 "v2ray.com/core/common/serial" 9 . "v2ray.com/core/infra/conf" 10 "v2ray.com/core/proxy/vless" 11 "v2ray.com/core/proxy/vless/inbound" 12 "v2ray.com/core/proxy/vless/outbound" 13 ) 14 15 func TestVLessOutbound(t *testing.T) { 16 creator := func() Buildable { 17 return new(VLessOutboundConfig) 18 } 19 20 runMultiTestCase(t, []TestCase{ 21 { 22 Input: `{ 23 "vnext": [{ 24 "address": "example.com", 25 "port": 443, 26 "users": [ 27 { 28 "id": "27848739-7e62-4138-9fd3-098a63964b6b", 29 "flow": "xtls-rprx-origin-udp443", 30 "encryption": "none", 31 "level": 0 32 } 33 ] 34 }] 35 }`, 36 Parser: loadJSON(creator), 37 Output: &outbound.Config{ 38 Vnext: []*protocol.ServerEndpoint{ 39 { 40 Address: &net.IPOrDomain{ 41 Address: &net.IPOrDomain_Domain{ 42 Domain: "example.com", 43 }, 44 }, 45 Port: 443, 46 User: []*protocol.User{ 47 { 48 Account: serial.ToTypedMessage(&vless.Account{ 49 Id: "27848739-7e62-4138-9fd3-098a63964b6b", 50 Flow: "xtls-rprx-origin-udp443", 51 Encryption: "none", 52 }), 53 Level: 0, 54 }, 55 }, 56 }, 57 }, 58 }, 59 }, 60 }) 61 } 62 63 func TestVLessInbound(t *testing.T) { 64 creator := func() Buildable { 65 return new(VLessInboundConfig) 66 } 67 68 runMultiTestCase(t, []TestCase{ 69 { 70 Input: `{ 71 "clients": [ 72 { 73 "id": "27848739-7e62-4138-9fd3-098a63964b6b", 74 "flow": "xtls-rprx-origin", 75 "level": 0, 76 "email": "love@v2fly.org" 77 } 78 ], 79 "decryption": "none", 80 "fallbacks": [ 81 { 82 "dest": 80 83 }, 84 { 85 "alpn": "h2", 86 "dest": "@/dev/shm/domain.socket", 87 "xver": 2 88 }, 89 { 90 "path": "/innerws", 91 "dest": "serve-ws-none" 92 } 93 ] 94 }`, 95 Parser: loadJSON(creator), 96 Output: &inbound.Config{ 97 Clients: []*protocol.User{ 98 { 99 Account: serial.ToTypedMessage(&vless.Account{ 100 Id: "27848739-7e62-4138-9fd3-098a63964b6b", 101 Flow: "xtls-rprx-origin", 102 }), 103 Level: 0, 104 Email: "love@v2fly.org", 105 }, 106 }, 107 Decryption: "none", 108 Fallbacks: []*inbound.Fallback{ 109 { 110 Alpn: "", 111 Path: "", 112 Type: "tcp", 113 Dest: "127.0.0.1:80", 114 Xver: 0, 115 }, 116 { 117 Alpn: "h2", 118 Path: "", 119 Type: "unix", 120 Dest: "@/dev/shm/domain.socket", 121 Xver: 2, 122 }, 123 { 124 Alpn: "", 125 Path: "/innerws", 126 Type: "serve", 127 Dest: "serve-ws-none", 128 Xver: 0, 129 }, 130 }, 131 }, 132 }, 133 }) 134 }