@@ -66,14 +66,11 @@ it("should throw error if proxy connect timeout", async () => {
6666 const addr = blackHole . address ( ) as net . AddressInfo ;
6767
6868 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 } ,
7774 } ) ;
7875 const promise = fetch ( "https://example.com" , { dispatcher } ) ;
7976 await expect ( promise ) . rejects . toThrow ( new TypeError ( "fetch failed" ) ) ;
@@ -83,11 +80,9 @@ it("should throw error if proxy connect timeout", async () => {
8380
8481it ( "should throw error if the socks server is unreachable" , async ( ) => {
8582 const dispatcher = socksDispatcher ( {
86- proxy : {
87- type : 5 ,
88- host : "::1" ,
89- port : 111 ,
90- } ,
83+ type : 5 ,
84+ host : "::1" ,
85+ port : 111 ,
9186 } ) ;
9287 await httpServer . forGet ( "/foobar" ) . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
9388
@@ -98,13 +93,11 @@ it("should throw error if the socks server is unreachable", async () => {
9893
9994it ( "should throw error if the target is unreachable" , async ( ) => {
10095 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_" ,
108101 } ) ;
109102 await httpServer . forGet ( "/foobar" ) . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
110103 const promise = fetch ( httpServer . urlFor ( "/foobar" ) , { dispatcher } ) ;
@@ -113,23 +106,19 @@ it("should throw error if the target is unreachable", async () => {
113106
114107it ( "should throw error if authenticate failed" , async ( ) => {
115108 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 ,
121112 } ) ;
122113 const promise = fetch ( "http://[::1]:111" , { dispatcher } ) ;
123114 await expect ( promise ) . rejects . toThrow ( new TypeError ( "fetch failed" ) ) ;
124115} ) ;
125116
126117it ( "should connect target through socks" , async ( ) => {
127118 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 ,
133122 } ) ;
134123 const ep = await httpServer . forGet ( "/foobar" )
135124 . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
@@ -143,19 +132,17 @@ it("should connect target through socks", async () => {
143132} ) ;
144133
145134it ( "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+ } ] ) ;
159146 const ep = await httpServer . forGet ( "/foobar" )
160147 . thenReply ( 200 , "__RESPONSE_DATA__" ) ;
161148
@@ -171,11 +158,10 @@ it("should support proxy chain", async () => {
171158
172159it ( "should support TLS over socks" , async ( ) => {
173160 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+ } , {
179165 connect : {
180166 rejectUnauthorized : false ,
181167 } ,
0 commit comments