validateSpecificProxy method
Validates a specific proxy
proxy
is the proxy to validate
testUrl
is the URL to use for testing
timeout
is the timeout in milliseconds
updateScore
determines whether to update the proxy's score
Implementation
Future<bool> validateSpecificProxy(
Proxy proxy, {
String? testUrl,
int timeout = 10000,
bool updateScore = true,
}) async {
final startTime = DateTime.now().millisecondsSinceEpoch;
final isValid = await validateProxy(
proxy,
testUrl: testUrl,
timeout: timeout,
);
final endTime = DateTime.now().millisecondsSinceEpoch;
final responseTime = endTime - startTime;
// Update the proxy's score if requested and it's a ProxyModel
if (updateScore && proxy is ProxyModel) {
final updatedProxy =
isValid
? proxy.withSuccessfulRequest(responseTime)
: proxy.withFailedRequest();
// Update the proxy in the lists
_updateProxyInLists(proxy, updatedProxy);
}
return isValid;
}