@@ -66,14 +66,11 @@ it("should throw error if proxy connect timeout", async () => {
66
66
const addr = blackHole . address ( ) as net . AddressInfo ;
67
67
68
68
const dispatcher = socksDispatcher ( {
69
- proxy : {
70
- type : 5 ,
71
- host : addr . address ,
72
- port : addr . port ,
73
- } ,
74
- connect : {
75
- timeout : 500 ,
76
- } ,
69
+ type : 5 ,
70
+ host : addr . address ,
71
+ port : addr . port ,
72
+ } , {
73
+ connect : { timeout : 500 } ,
77
74
} ) ;
78
75
const promise = fetch ( "https://example.com" , { dispatcher } ) ;
79
76
await expect ( promise ) . rejects . toThrow ( new TypeError ( "fetch failed" ) ) ;
@@ -83,11 +80,9 @@ it("should throw error if proxy connect timeout", async () => {
83
80
84
81
it ( "should throw error if the socks server is unreachable" , async ( ) => {
85
82
const dispatcher = socksDispatcher ( {
86
- proxy : {
87
- type : 5 ,
88
- host : "::1" ,
89
- port : 111 ,
90
- } ,
83
+ type : 5 ,
84
+ host : "::1" ,
85
+ port : 111 ,
91
86
} ) ;
92
87
await httpServer . forGet ( "/foobar" ) . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
93
88
@@ -98,13 +93,11 @@ it("should throw error if the socks server is unreachable", async () => {
98
93
99
94
it ( "should throw error if the target is unreachable" , async ( ) => {
100
95
const dispatcher = socksDispatcher ( {
101
- proxy : {
102
- type : 5 ,
103
- host : secureProxy . address ,
104
- port : secureProxy . port ,
105
- userId : "foo" ,
106
- password : "_INVALID_" ,
107
- } ,
96
+ type : 5 ,
97
+ host : secureProxy . address ,
98
+ port : secureProxy . port ,
99
+ userId : "foo" ,
100
+ password : "_INVALID_" ,
108
101
} ) ;
109
102
await httpServer . forGet ( "/foobar" ) . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
110
103
const promise = fetch ( httpServer . urlFor ( "/foobar" ) , { dispatcher } ) ;
@@ -113,23 +106,19 @@ it("should throw error if the target is unreachable", async () => {
113
106
114
107
it ( "should throw error if authenticate failed" , async ( ) => {
115
108
const dispatcher = socksDispatcher ( {
116
- proxy : {
117
- type : 5 ,
118
- host : plainProxy . address ,
119
- port : plainProxy . port ,
120
- } ,
109
+ type : 5 ,
110
+ host : plainProxy . address ,
111
+ port : plainProxy . port ,
121
112
} ) ;
122
113
const promise = fetch ( "http://[::1]:111" , { dispatcher } ) ;
123
114
await expect ( promise ) . rejects . toThrow ( new TypeError ( "fetch failed" ) ) ;
124
115
} ) ;
125
116
126
117
it ( "should connect target through socks" , async ( ) => {
127
118
const dispatcher = socksDispatcher ( {
128
- proxy : {
129
- type : 5 ,
130
- host : plainProxy . address ,
131
- port : plainProxy . port ,
132
- } ,
119
+ type : 5 ,
120
+ host : plainProxy . address ,
121
+ port : plainProxy . port ,
133
122
} ) ;
134
123
const ep = await httpServer . forGet ( "/foobar" )
135
124
. thenReply ( 200 , "__RESPONSE_DATA__" ) ;
@@ -143,19 +132,17 @@ it("should connect target through socks", async () => {
143
132
} ) ;
144
133
145
134
it ( "should support proxy chain" , async ( ) => {
146
- const dispatcher = socksDispatcher ( {
147
- proxy : [ {
148
- type : 5 ,
149
- host : secureProxy . address ,
150
- port : secureProxy . port ,
151
- userId : "foo" ,
152
- password : "bar" ,
153
- } , {
154
- type : 5 ,
155
- host : plainProxy . address ,
156
- port : plainProxy . port ,
157
- } ] ,
158
- } ) ;
135
+ const dispatcher = socksDispatcher ( [ {
136
+ type : 5 ,
137
+ host : secureProxy . address ,
138
+ port : secureProxy . port ,
139
+ userId : "foo" ,
140
+ password : "bar" ,
141
+ } , {
142
+ type : 5 ,
143
+ host : plainProxy . address ,
144
+ port : plainProxy . port ,
145
+ } ] ) ;
159
146
const ep = await httpServer . forGet ( "/foobar" )
160
147
. thenReply ( 200 , "__RESPONSE_DATA__" ) ;
161
148
@@ -171,11 +158,10 @@ it("should support proxy chain", async () => {
171
158
172
159
it ( "should support TLS over socks" , async ( ) => {
173
160
const dispatcher = socksDispatcher ( {
174
- proxy : {
175
- type : 5 ,
176
- host : plainProxy . address ,
177
- port : plainProxy . port ,
178
- } ,
161
+ type : 5 ,
162
+ host : plainProxy . address ,
163
+ port : plainProxy . port ,
164
+ } , {
179
165
connect : {
180
166
rejectUnauthorized : false ,
181
167
} ,
0 commit comments