@@ -300,6 +300,125 @@ func BenchmarkSSProxyParallel(b *testing.B) {
300
300
})
301
301
}
302
302
303
+ var ssuTests = []struct {
304
+ clientCipher * url.Userinfo
305
+ serverCipher * url.Userinfo
306
+ pass bool
307
+ }{
308
+ {nil , nil , true },
309
+ {& url.Userinfo {}, & url.Userinfo {}, true },
310
+ {url .User ("abc" ), url .User ("abc" ), true },
311
+ {url .UserPassword ("abc" , "def" ), url .UserPassword ("abc" , "def" ), true },
312
+
313
+ {url .User ("aes-128-cfb" ), url .User ("aes-128-cfb" ), true },
314
+ {url .User ("aes-128-cfb" ), url .UserPassword ("aes-128-cfb" , "123456" ), false },
315
+ {url .UserPassword ("aes-128-cfb" , "123456" ), url .User ("aes-128-cfb" ), false },
316
+ {url .UserPassword ("aes-128-cfb" , "123456" ), url .UserPassword ("aes-128-cfb" , "abc" ), false },
317
+ {url .UserPassword ("aes-128-cfb" , "123456" ), url .UserPassword ("aes-128-cfb" , "123456" ), true },
318
+
319
+ {url .User ("aes-192-cfb" ), url .User ("aes-192-cfb" ), true },
320
+ {url .User ("aes-192-cfb" ), url .UserPassword ("aes-192-cfb" , "123456" ), false },
321
+ {url .UserPassword ("aes-192-cfb" , "123456" ), url .User ("aes-192-cfb" ), false },
322
+ {url .UserPassword ("aes-192-cfb" , "123456" ), url .UserPassword ("aes-192-cfb" , "abc" ), false },
323
+ {url .UserPassword ("aes-192-cfb" , "123456" ), url .UserPassword ("aes-192-cfb" , "123456" ), true },
324
+
325
+ {url .User ("aes-256-cfb" ), url .User ("aes-256-cfb" ), true },
326
+ {url .User ("aes-256-cfb" ), url .UserPassword ("aes-256-cfb" , "123456" ), false },
327
+ {url .UserPassword ("aes-256-cfb" , "123456" ), url .User ("aes-256-cfb" ), false },
328
+ {url .UserPassword ("aes-256-cfb" , "123456" ), url .UserPassword ("aes-256-cfb" , "abc" ), false },
329
+ {url .UserPassword ("aes-256-cfb" , "123456" ), url .UserPassword ("aes-256-cfb" , "123456" ), true },
330
+
331
+ {url .User ("aes-128-ctr" ), url .User ("aes-128-ctr" ), true },
332
+ {url .User ("aes-128-ctr" ), url .UserPassword ("aes-128-ctr" , "123456" ), false },
333
+ {url .UserPassword ("aes-128-ctr" , "123456" ), url .User ("aes-128-ctr" ), false },
334
+ {url .UserPassword ("aes-128-ctr" , "123456" ), url .UserPassword ("aes-128-ctr" , "abc" ), false },
335
+ {url .UserPassword ("aes-128-ctr" , "123456" ), url .UserPassword ("aes-128-ctr" , "123456" ), true },
336
+
337
+ {url .User ("aes-192-ctr" ), url .User ("aes-192-ctr" ), true },
338
+ {url .User ("aes-192-ctr" ), url .UserPassword ("aes-192-ctr" , "123456" ), false },
339
+ {url .UserPassword ("aes-192-ctr" , "123456" ), url .User ("aes-192-ctr" ), false },
340
+ {url .UserPassword ("aes-192-ctr" , "123456" ), url .UserPassword ("aes-192-ctr" , "abc" ), false },
341
+ {url .UserPassword ("aes-192-ctr" , "123456" ), url .UserPassword ("aes-192-ctr" , "123456" ), true },
342
+
343
+ {url .User ("aes-256-ctr" ), url .User ("aes-256-ctr" ), true },
344
+ {url .User ("aes-256-ctr" ), url .UserPassword ("aes-256-ctr" , "123456" ), false },
345
+ {url .UserPassword ("aes-256-ctr" , "123456" ), url .User ("aes-256-ctr" ), false },
346
+ {url .UserPassword ("aes-256-ctr" , "123456" ), url .UserPassword ("aes-256-ctr" , "abc" ), false },
347
+ {url .UserPassword ("aes-256-ctr" , "123456" ), url .UserPassword ("aes-256-ctr" , "123456" ), true },
348
+
349
+ {url .User ("des-cfb" ), url .User ("des-cfb" ), true },
350
+ {url .User ("des-cfb" ), url .UserPassword ("des-cfb" , "123456" ), false },
351
+ {url .UserPassword ("des-cfb" , "123456" ), url .User ("des-cfb" ), false },
352
+ {url .UserPassword ("des-cfb" , "123456" ), url .UserPassword ("des-cfb" , "abc" ), false },
353
+ {url .UserPassword ("des-cfb" , "123456" ), url .UserPassword ("des-cfb" , "123456" ), true },
354
+
355
+ {url .User ("bf-cfb" ), url .User ("bf-cfb" ), true },
356
+ {url .User ("bf-cfb" ), url .UserPassword ("bf-cfb" , "123456" ), false },
357
+ {url .UserPassword ("bf-cfb" , "123456" ), url .User ("bf-cfb" ), false },
358
+ {url .UserPassword ("bf-cfb" , "123456" ), url .UserPassword ("bf-cfb" , "abc" ), false },
359
+ {url .UserPassword ("bf-cfb" , "123456" ), url .UserPassword ("bf-cfb" , "123456" ), true },
360
+
361
+ {url .User ("cast5-cfb" ), url .User ("cast5-cfb" ), true },
362
+ {url .User ("cast5-cfb" ), url .UserPassword ("cast5-cfb" , "123456" ), false },
363
+ {url .UserPassword ("cast5-cfb" , "123456" ), url .User ("cast5-cfb" ), false },
364
+ {url .UserPassword ("cast5-cfb" , "123456" ), url .UserPassword ("cast5-cfb" , "abc" ), false },
365
+ {url .UserPassword ("cast5-cfb" , "123456" ), url .UserPassword ("cast5-cfb" , "123456" ), true },
366
+
367
+ {url .User ("rc4-md5" ), url .User ("rc4-md5" ), true },
368
+ {url .User ("rc4-md5" ), url .UserPassword ("rc4-md5" , "123456" ), false },
369
+ {url .UserPassword ("rc4-md5" , "123456" ), url .User ("rc4-md5" ), false },
370
+ {url .UserPassword ("rc4-md5" , "123456" ), url .UserPassword ("rc4-md5" , "abc" ), false },
371
+ {url .UserPassword ("rc4-md5" , "123456" ), url .UserPassword ("rc4-md5" , "123456" ), true },
372
+
373
+ {url .User ("chacha20" ), url .User ("chacha20" ), true },
374
+ {url .User ("chacha20" ), url .UserPassword ("chacha20" , "123456" ), false },
375
+ {url .UserPassword ("chacha20" , "123456" ), url .User ("chacha20" ), false },
376
+ {url .UserPassword ("chacha20" , "123456" ), url .UserPassword ("chacha20" , "abc" ), false },
377
+ {url .UserPassword ("chacha20" , "123456" ), url .UserPassword ("chacha20" , "123456" ), true },
378
+
379
+ {url .User ("chacha20-ietf" ), url .User ("chacha20-ietf" ), true },
380
+ {url .User ("chacha20-ietf" ), url .UserPassword ("chacha20-ietf" , "123456" ), false },
381
+ {url .UserPassword ("chacha20-ietf" , "123456" ), url .User ("chacha20-ietf" ), false },
382
+ {url .UserPassword ("chacha20-ietf" , "123456" ), url .UserPassword ("chacha20-ietf" , "abc" ), false },
383
+ {url .UserPassword ("chacha20-ietf" , "123456" ), url .UserPassword ("chacha20-ietf" , "123456" ), true },
384
+
385
+ {url .User ("salsa20" ), url .User ("salsa20" ), true },
386
+ {url .User ("salsa20" ), url .UserPassword ("salsa20" , "123456" ), false },
387
+ {url .UserPassword ("salsa20" , "123456" ), url .User ("salsa20" ), false },
388
+ {url .UserPassword ("salsa20" , "123456" ), url .UserPassword ("salsa20" , "abc" ), false },
389
+ {url .UserPassword ("salsa20" , "123456" ), url .UserPassword ("salsa20" , "123456" ), true },
390
+
391
+ {url .User ("xchacha20" ), url .User ("xchacha20" ), true },
392
+ {url .User ("xchacha20" ), url .UserPassword ("xchacha20" , "123456" ), false },
393
+ {url .UserPassword ("xchacha20" , "123456" ), url .User ("xchacha20" ), false },
394
+ {url .UserPassword ("xchacha20" , "123456" ), url .UserPassword ("xchacha20" , "abc" ), false },
395
+ {url .UserPassword ("xchacha20" , "123456" ), url .UserPassword ("xchacha20" , "123456" ), true },
396
+
397
+ {url .User ("CHACHA20-IETF-POLY1305" ), url .User ("CHACHA20-IETF-POLY1305" ), true },
398
+ {url .User ("CHACHA20-IETF-POLY1305" ), url .UserPassword ("CHACHA20-IETF-POLY1305" , "123456" ), false },
399
+ {url .UserPassword ("CHACHA20-IETF-POLY1305" , "123456" ), url .User ("CHACHA20-IETF-POLY1305" ), false },
400
+ {url .UserPassword ("CHACHA20-IETF-POLY1305" , "123456" ), url .UserPassword ("CHACHA20-IETF-POLY1305" , "abc" ), false },
401
+ {url .UserPassword ("CHACHA20-IETF-POLY1305" , "123456" ), url .UserPassword ("CHACHA20-IETF-POLY1305" , "123456" ), true },
402
+
403
+ {url .User ("AES-128-GCM" ), url .User ("AES-128-GCM" ), true },
404
+ {url .User ("AES-128-GCM" ), url .UserPassword ("AES-128-GCM" , "123456" ), false },
405
+ {url .UserPassword ("AES-128-GCM" , "123456" ), url .User ("AES-128-GCM" ), false },
406
+ {url .UserPassword ("AES-128-GCM" , "123456" ), url .UserPassword ("AES-128-GCM" , "abc" ), false },
407
+ {url .UserPassword ("AES-128-GCM" , "123456" ), url .UserPassword ("AES-128-GCM" , "123456" ), true },
408
+
409
+ {url .User ("AES-192-GCM" ), url .User ("AES-192-GCM" ), true },
410
+ {url .User ("AES-192-GCM" ), url .UserPassword ("AES-192-GCM" , "123456" ), false },
411
+ {url .UserPassword ("AES-192-GCM" , "123456" ), url .User ("AES-192-GCM" ), false },
412
+ {url .UserPassword ("AES-192-GCM" , "123456" ), url .UserPassword ("AES-192-GCM" , "abc" ), false },
413
+ {url .UserPassword ("AES-192-GCM" , "123456" ), url .UserPassword ("AES-192-GCM" , "123456" ), true },
414
+
415
+ {url .User ("AES-256-GCM" ), url .User ("AES-256-GCM" ), true },
416
+ {url .User ("AES-256-GCM" ), url .UserPassword ("AES-256-GCM" , "123456" ), false },
417
+ {url .UserPassword ("AES-256-GCM" , "123456" ), url .User ("AES-256-GCM" ), false },
418
+ {url .UserPassword ("AES-256-GCM" , "123456" ), url .UserPassword ("AES-256-GCM" , "abc" ), false },
419
+ {url .UserPassword ("AES-256-GCM" , "123456" ), url .UserPassword ("AES-256-GCM" , "123456" ), true },
420
+ }
421
+
303
422
func shadowUDPRoundtrip (t * testing.T , host string , data []byte ,
304
423
clientInfo * url.Userinfo , serverInfo * url.Userinfo ) error {
305
424
ln , err := UDPListener ("localhost:0" , nil )
@@ -329,7 +448,7 @@ func TestShadowUDP(t *testing.T) {
329
448
sendData := make ([]byte , 128 )
330
449
rand .Read (sendData )
331
450
332
- for i , tc := range ssTests {
451
+ for i , tc := range ssuTests {
333
452
tc := tc
334
453
t .Run (fmt .Sprintf ("#%d" , i ), func (t * testing.T ) {
335
454
udpSrv := newUDPTestServer (udpTestHandler )
@@ -354,7 +473,6 @@ func TestShadowUDP(t *testing.T) {
354
473
}
355
474
}
356
475
357
- // TODO: fix shadowsocks UDP relay benchmark.
358
476
func BenchmarkShadowUDP (b * testing.B ) {
359
477
udpSrv := newUDPTestServer (udpTestHandler )
360
478
udpSrv .Start ()
0 commit comments