|
1 | | -package main |
| 1 | +package command |
2 | 2 |
|
3 | 3 | import ( |
4 | 4 | "net/url" |
5 | 5 | "strings" |
6 | 6 | "testing" |
7 | 7 |
|
8 | 8 | "github.com/stretchr/testify/require" |
| 9 | + "github.com/v-byte-cpu/wirez/pkg/connect" |
9 | 10 | ) |
10 | 11 |
|
11 | 12 | func TestParseProxyFile(t *testing.T) { |
12 | 13 | tests := []struct { |
13 | 14 | name string |
14 | 15 | input string |
15 | | - expected []*SocksAddr |
| 16 | + expected []*connect.SocksAddr |
16 | 17 | expectedErr bool |
17 | 18 | }{ |
18 | 19 | { |
@@ -46,52 +47,52 @@ func TestParseProxyFile(t *testing.T) { |
46 | 47 | { |
47 | 48 | name: "OneIPPort", |
48 | 49 | input: "10.10.10.10:1111", |
49 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111"}}, |
| 50 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111"}}, |
50 | 51 | }, |
51 | 52 | { |
52 | 53 | name: "OneIPPortWithSpaces", |
53 | 54 | input: " 10.10.10.10:1111 ", |
54 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111"}}, |
| 55 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111"}}, |
55 | 56 | }, |
56 | 57 | { |
57 | 58 | name: "OneHostPort", |
58 | 59 | input: "example.com:1111", |
59 | | - expected: []*SocksAddr{{Address: "example.com:1111"}}, |
| 60 | + expected: []*connect.SocksAddr{{Address: "example.com:1111"}}, |
60 | 61 | }, |
61 | 62 | { |
62 | 63 | name: "TwoIPPortLines", |
63 | 64 | input: "10.10.10.10:1111\n20.20.20.20:2222", |
64 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111"}, {Address: "20.20.20.20:2222"}}, |
| 65 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111"}, {Address: "20.20.20.20:2222"}}, |
65 | 66 | }, |
66 | 67 | { |
67 | 68 | name: "TwoHostPortLines", |
68 | 69 | input: "example.com:1111\nexample.org:2222", |
69 | | - expected: []*SocksAddr{{Address: "example.com:1111"}, {Address: "example.org:2222"}}, |
| 70 | + expected: []*connect.SocksAddr{{Address: "example.com:1111"}, {Address: "example.org:2222"}}, |
70 | 71 | }, |
71 | 72 | { |
72 | 73 | name: "OneIPPortWithUsername", |
73 | 74 | |
74 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111", Auth: url.User("abc")}}, |
| 75 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111", Auth: url.User("abc")}}, |
75 | 76 | }, |
76 | 77 | { |
77 | 78 | name: "OneIPPortWithUsernamePassword", |
78 | 79 | input: "abc:[email protected]:1111", |
79 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111", Auth: url.UserPassword("abc", "def")}}, |
| 80 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111", Auth: url.UserPassword("abc", "def")}}, |
80 | 81 | }, |
81 | 82 | { |
82 | 83 | name: "OneHostPortWithUsernamePassword", |
83 | 84 | input: "abc:[email protected]:1111", |
84 | | - expected: []*SocksAddr{{Address: "example.com:1111", Auth: url.UserPassword("abc", "def")}}, |
| 85 | + expected: []*connect.SocksAddr{{Address: "example.com:1111", Auth: url.UserPassword("abc", "def")}}, |
85 | 86 | }, |
86 | 87 | { |
87 | 88 | name: "WithSocks5Scheme", |
88 | 89 | input: "socks5://10.10.10.10:1111", |
89 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111"}}, |
| 90 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111"}}, |
90 | 91 | }, |
91 | 92 | { |
92 | 93 | name: "TwoWithSocks5Schemes", |
93 | 94 | input: "socks5://10.10.10.10:1111\nsocks5://20.20.20.20:2221", |
94 | | - expected: []*SocksAddr{{Address: "10.10.10.10:1111"}, {Address: "20.20.20.20:2221"}}, |
| 95 | + expected: []*connect.SocksAddr{{Address: "10.10.10.10:1111"}, {Address: "20.20.20.20:2221"}}, |
95 | 96 | }, |
96 | 97 | { |
97 | 98 | name: "WithInvalidScheme", |
|
0 commit comments