don't check for duplicates when getting a proxy

This commit is contained in:
Cyberes 2024-04-12 20:47:55 -06:00
parent 5273d1b16f
commit d10c84d974
2 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,7 @@ func (p *ForwardProxyCluster) cycleProxy(validProxies []string, currentProxy *in
func (p *ForwardProxyCluster) getProxyFromAll() string { func (p *ForwardProxyCluster) getProxyFromAll() string {
p.mu.RLock() p.mu.RLock()
defer p.mu.RUnlock() defer p.mu.RUnlock()
validProxies := removeDuplicates(append(p.ourOnlineProxies, p.thirdpartyOnlineProxies...)) validProxies := append(p.ourOnlineProxies, p.thirdpartyOnlineProxies...)
return p.cycleProxy(validProxies, &p.currentProxyAll) return p.cycleProxy(validProxies, &p.currentProxyAll)
} }
@ -68,7 +68,7 @@ func (p *ForwardProxyCluster) getProxyFromOurs() string {
func (p *ForwardProxyCluster) getProxyFromAllWithBroken() string { func (p *ForwardProxyCluster) getProxyFromAllWithBroken() string {
p.mu.RLock() p.mu.RLock()
defer p.mu.RUnlock() defer p.mu.RUnlock()
validProxies := removeDuplicates(slices.Concat(p.ourOnlineProxies, p.thirdpartyBrokenProxies, p.thirdpartyOnlineProxies)) validProxies := slices.Concat(p.ourOnlineProxies, p.thirdpartyBrokenProxies, p.thirdpartyOnlineProxies)
return p.cycleProxy(validProxies, &p.currentProxyAllWithBroken) return p.cycleProxy(validProxies, &p.currentProxyAllWithBroken)
} }

View File

@ -72,10 +72,10 @@ func (p *ForwardProxyCluster) ValidateProxiesThread() {
wg.Wait() wg.Wait()
p.mu.Lock() p.mu.Lock()
p.ourOnlineProxies = newOurOnlineProxies p.ourOnlineProxies = removeDuplicates(newOurOnlineProxies)
p.thirdpartyOnlineProxies = newThirdpartyOnlineProxies p.thirdpartyOnlineProxies = removeDuplicates(newThirdpartyOnlineProxies)
p.thirdpartyBrokenProxies = newThirdpartyBrokenProxies p.thirdpartyBrokenProxies = removeDuplicates(newThirdpartyBrokenProxies)
p.ipAddresses = newIpAddresses p.ipAddresses = removeDuplicates(newIpAddresses)
p.mu.Unlock() p.mu.Unlock()
if !started { if !started {