@@ -59,7 +59,7 @@ public async Task DownloadFileAsync(string url, string fileName, bool blProxy, i
59
59
UpdateCompleted ? . Invoke ( this , new RetResult ( value > 100 , $ "...{ value } %") ) ;
60
60
} ;
61
61
62
- var webProxy = GetWebProxy ( blProxy ) ;
62
+ var webProxy = await GetWebProxy ( blProxy ) ;
63
63
await DownloaderHelper . Instance . DownloadFileAsync ( webProxy ,
64
64
url ,
65
65
fileName ,
@@ -84,7 +84,7 @@ await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
84
84
var webRequestHandler = new SocketsHttpHandler
85
85
{
86
86
AllowAutoRedirect = false ,
87
- Proxy = GetWebProxy ( blProxy )
87
+ Proxy = await GetWebProxy ( blProxy )
88
88
} ;
89
89
HttpClient client = new ( webRequestHandler ) ;
90
90
@@ -151,7 +151,7 @@ await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
151
151
try
152
152
{
153
153
SetSecurityProtocol ( AppHandler . Instance . Config . guiItem . enableSecurityProtocolTls13 ) ;
154
- var webProxy = GetWebProxy ( blProxy ) ;
154
+ var webProxy = await GetWebProxy ( blProxy ) ;
155
155
var client = new HttpClient ( new SocketsHttpHandler ( )
156
156
{
157
157
Proxy = webProxy ,
@@ -197,7 +197,7 @@ await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
197
197
{
198
198
SetSecurityProtocol ( AppHandler . Instance . Config . guiItem . enableSecurityProtocolTls13 ) ;
199
199
200
- var webProxy = GetWebProxy ( blProxy ) ;
200
+ var webProxy = await GetWebProxy ( blProxy ) ;
201
201
202
202
if ( Utils . IsNullOrEmpty ( userAgent ) )
203
203
{
@@ -222,7 +222,7 @@ public async Task<int> RunAvailabilityCheck(IWebProxy? webProxy)
222
222
{
223
223
try
224
224
{
225
- webProxy ??= GetWebProxy ( true ) ;
225
+ webProxy ??= await GetWebProxy ( true ) ;
226
226
227
227
try
228
228
{
@@ -274,28 +274,28 @@ public async Task<int> GetRealPingTime(string url, IWebProxy? webProxy, int down
274
274
return responseTime ;
275
275
}
276
276
277
- private WebProxy ? GetWebProxy ( bool blProxy )
277
+ private async Task < WebProxy ? > GetWebProxy ( bool blProxy )
278
278
{
279
279
if ( ! blProxy )
280
280
{
281
281
return null ;
282
282
}
283
283
var httpPort = AppHandler . Instance . GetLocalPort ( EInboundProtocol . http ) ;
284
- if ( ! SocketCheck ( Global . Loopback , httpPort ) )
284
+ if ( await SocketCheck ( Global . Loopback , httpPort ) == false )
285
285
{
286
286
return null ;
287
287
}
288
288
289
289
return new WebProxy ( Global . Loopback , httpPort ) ;
290
290
}
291
291
292
- private bool SocketCheck ( string ip , int port )
292
+ private async Task < bool > SocketCheck ( string ip , int port )
293
293
{
294
294
try
295
295
{
296
296
IPEndPoint point = new ( IPAddress . Parse ( ip ) , port ) ;
297
297
using Socket ? sock = new ( AddressFamily . InterNetwork , SocketType . Stream , ProtocolType . Tcp ) ;
298
- sock . Connect ( point ) ;
298
+ await sock . ConnectAsync ( point ) ;
299
299
return true ;
300
300
}
301
301
catch ( Exception )
0 commit comments