getRandomProxy method
Gets a random proxy
validated
determines whether to use validated proxies
useScoring
determines whether to use the scoring system for weighted selection
Implementation
Proxy getRandomProxy({bool validated = true, bool useScoring = false}) {
final proxies = validated ? _validatedProxies : _proxies;
if (proxies.isEmpty) {
throw NoValidProxiesException();
}
if (useScoring) {
// Use weighted selection based on proxy scores
return getNextProxy(
validated: validated,
useScoring: true,
strategyType: RotationStrategyType.weighted,
);
} else {
// Use simple random selection
_rotationStrategy = RotationStrategyFactory.createStrategy(
type: RotationStrategyType.random,
proxies: proxies,
);
return _rotationStrategy.selectProxy(proxies);
}
}