File size: 437 Bytes
931bd01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package proxys

import "sync"

type IProxy struct {
	ips  []string
	lock sync.Mutex
}

func NewIProxyIP(ips []string) IProxy {
	return IProxy{
		ips: ips,
	}
}

func (p *IProxy) GetIPS() int {
	return len(p.ips)
}

func (p *IProxy) GetProxyIP() string {
	if p == nil {
		return ""
	}

	p.lock.Lock()
	defer p.lock.Unlock()

	if len(p.ips) == 0 {
		return ""
	}

	proxyIp := p.ips[0]
	p.ips = append(p.ips[1:], proxyIp)
	return proxyIp
}