@@ -216,8 +216,8 @@ public async Task<RetResult> GenerateClientSpeedtestConfig(List<ServerTestItem>
216216
217217 ret . Msg = ResUI . InitialConfiguration ;
218218
219- string result = Utils . GetEmbedText ( Global . V2raySampleClient ) ;
220- string txtOutbound = Utils . GetEmbedText ( Global . V2raySampleOutbound ) ;
219+ var result = Utils . GetEmbedText ( Global . V2raySampleClient ) ;
220+ var txtOutbound = Utils . GetEmbedText ( Global . V2raySampleOutbound ) ;
221221 if ( Utils . IsNullOrEmpty ( result ) || txtOutbound . IsNullOrEmpty ( ) )
222222 {
223223 ret . Msg = ResUI . FailedGetDefaultConfiguration ;
@@ -244,10 +244,11 @@ public async Task<RetResult> GenerateClientSpeedtestConfig(List<ServerTestItem>
244244 }
245245
246246 await GenLog ( v2rayConfig ) ;
247- v2rayConfig . inbounds . Clear ( ) ; // Remove "proxy" service for speedtest, avoiding port conflicts.
248- v2rayConfig . outbounds . RemoveAt ( 0 ) ;
247+ v2rayConfig . inbounds . Clear ( ) ;
248+ v2rayConfig . outbounds . Clear ( ) ;
249+ v2rayConfig . routing . rules . Clear ( ) ;
249250
250- int httpPort = AppHandler . Instance . GetLocalPort ( EInboundProtocol . speedtest ) ;
251+ var httpPort = AppHandler . Instance . GetLocalPort ( EInboundProtocol . speedtest ) ;
251252
252253 foreach ( var it in selecteds )
253254 {
@@ -270,7 +271,7 @@ public async Task<RetResult> GenerateClientSpeedtestConfig(List<ServerTestItem>
270271
271272 //find unused port
272273 var port = httpPort ;
273- for ( int k = httpPort ; k < Global . MaxPort ; k ++ )
274+ for ( var k = httpPort ; k < Global . MaxPort ; k ++ )
274275 {
275276 if ( lstIpEndPoints ? . FindIndex ( _it => _it . Port == k ) >= 0 )
276277 {
@@ -294,16 +295,6 @@ public async Task<RetResult> GenerateClientSpeedtestConfig(List<ServerTestItem>
294295 it . Port = port ;
295296 it . AllowTest = true ;
296297
297- //inbound
298- Inbounds4Ray inbound = new ( )
299- {
300- listen = Global . Loopback ,
301- port = port ,
302- protocol = EInboundProtocol . http . ToString ( ) ,
303- } ;
304- inbound . tag = inbound . protocol + inbound . port . ToString ( ) ;
305- v2rayConfig . inbounds . Add ( inbound ) ;
306-
307298 //outbound
308299 if ( item is null )
309300 {
@@ -325,6 +316,16 @@ public async Task<RetResult> GenerateClientSpeedtestConfig(List<ServerTestItem>
325316 {
326317 continue ;
327318 }
319+
320+ //inbound
321+ Inbounds4Ray inbound = new ( )
322+ {
323+ listen = Global . Loopback ,
324+ port = port ,
325+ protocol = EInboundProtocol . http . ToString ( ) ,
326+ } ;
327+ inbound . tag = inbound . protocol + inbound . port . ToString ( ) ;
328+ v2rayConfig . inbounds . Add ( inbound ) ;
328329
329330 var outbound = JsonUtils . Deserialize < Outbounds4Ray > ( txtOutbound ) ;
330331 await GenOutbound ( item , outbound ) ;
0 commit comments