@@ -4,16 +4,8 @@ import (
4
4
"encoding/json"
5
5
"testing"
6
6
7
- "github.com/xtls/xray-core/common/serial"
8
7
. "github.com/xtls/xray-core/infra/conf"
9
- "github.com/xtls/xray-core/transport/global"
10
8
"github.com/xtls/xray-core/transport/internet"
11
- "github.com/xtls/xray-core/transport/internet/grpc"
12
- "github.com/xtls/xray-core/transport/internet/headers/http"
13
- "github.com/xtls/xray-core/transport/internet/headers/noop"
14
- "github.com/xtls/xray-core/transport/internet/kcp"
15
- "github.com/xtls/xray-core/transport/internet/tcp"
16
- "github.com/xtls/xray-core/transport/internet/websocket"
17
9
"google.golang.org/protobuf/proto"
18
10
)
19
11
@@ -157,139 +149,3 @@ func TestSocketConfig(t *testing.T) {
157
149
t .Fatalf ("unexpected parsed TFO value, which should be -1" )
158
150
}
159
151
}
160
-
161
- func TestTransportConfig (t * testing.T ) {
162
- createParser := func () func (string ) (proto.Message , error ) {
163
- return func (s string ) (proto.Message , error ) {
164
- config := new (TransportConfig )
165
- if err := json .Unmarshal ([]byte (s ), config ); err != nil {
166
- return nil , err
167
- }
168
- return config .Build ()
169
- }
170
- }
171
-
172
- runMultiTestCase (t , []TestCase {
173
- {
174
- Input : `{
175
- "tcpSettings": {
176
- "header": {
177
- "type": "http",
178
- "request": {
179
- "version": "1.1",
180
- "method": "GET",
181
- "path": "/b",
182
- "headers": {
183
- "a": "b",
184
- "c": "d"
185
- }
186
- },
187
- "response": {
188
- "version": "1.0",
189
- "status": "404",
190
- "reason": "Not Found"
191
- }
192
- }
193
- },
194
- "kcpSettings": {
195
- "mtu": 1200,
196
- "header": {
197
- "type": "none"
198
- }
199
- },
200
- "wsSettings": {
201
- "path": "/t"
202
- },
203
- "grpcSettings": {
204
- "serviceName": "name",
205
- "multiMode": true
206
- }
207
- }` ,
208
- Parser : createParser (),
209
- Output : & global.Config {
210
- TransportSettings : []* internet.TransportConfig {
211
- {
212
- ProtocolName : "tcp" ,
213
- Settings : serial .ToTypedMessage (& tcp.Config {
214
- HeaderSettings : serial .ToTypedMessage (& http.Config {
215
- Request : & http.RequestConfig {
216
- Version : & http.Version {Value : "1.1" },
217
- Method : & http.Method {Value : "GET" },
218
- Uri : []string {"/b" },
219
- Header : []* http.Header {
220
- {Name : "a" , Value : []string {"b" }},
221
- {Name : "c" , Value : []string {"d" }},
222
- },
223
- },
224
- Response : & http.ResponseConfig {
225
- Version : & http.Version {Value : "1.0" },
226
- Status : & http.Status {Code : "404" , Reason : "Not Found" },
227
- Header : []* http.Header {
228
- {
229
- Name : "Content-Type" ,
230
- Value : []string {"application/octet-stream" , "video/mpeg" },
231
- },
232
- {
233
- Name : "Transfer-Encoding" ,
234
- Value : []string {"chunked" },
235
- },
236
- {
237
- Name : "Connection" ,
238
- Value : []string {"keep-alive" },
239
- },
240
- {
241
- Name : "Pragma" ,
242
- Value : []string {"no-cache" },
243
- },
244
- {
245
- Name : "Cache-Control" ,
246
- Value : []string {"private" , "no-cache" },
247
- },
248
- },
249
- },
250
- }),
251
- }),
252
- },
253
- {
254
- ProtocolName : "mkcp" ,
255
- Settings : serial .ToTypedMessage (& kcp.Config {
256
- Mtu : & kcp.MTU {Value : 1200 },
257
- HeaderConfig : serial .ToTypedMessage (& noop.Config {}),
258
- }),
259
- },
260
- {
261
- ProtocolName : "websocket" ,
262
- Settings : serial .ToTypedMessage (& websocket.Config {
263
- Path : "/t" ,
264
- }),
265
- },
266
- {
267
- ProtocolName : "grpc" ,
268
- Settings : serial .ToTypedMessage (& grpc.Config {
269
- ServiceName : "name" ,
270
- MultiMode : true ,
271
- }),
272
- },
273
- },
274
- },
275
- },
276
- {
277
- Input : `{
278
- "gunSettings": {
279
- "serviceName": "name"
280
- }
281
- }` ,
282
- Parser : createParser (),
283
- Output : & global.Config {
284
- TransportSettings : []* internet.TransportConfig {
285
- {
286
- ProtocolName : "grpc" ,
287
- Settings : serial .ToTypedMessage (& grpc.Config {
288
- ServiceName : "name" ,
289
- }),
290
- },
291
- },
292
- },
293
- },
294
- })
295
- }
0 commit comments