| skipped 1 lines |
2 | 2 | | |
3 | 3 | | import ( |
4 | 4 | | "bufio" |
| 5 | + | "fmt" |
5 | 6 | | "io" |
6 | 7 | | "os" |
7 | 8 | | "strings" |
| skipped 55 lines |
63 | 64 | | return |
64 | 65 | | } |
65 | 66 | | |
66 | | - | func (p5 *Swamp) loadSingleProxy(sock string) { |
| 67 | + | func (p5 *Swamp) loadSingleProxy(sock string) error { |
67 | 68 | | for { |
68 | 69 | | select { |
69 | 70 | | case inChan <- sock: |
70 | | - | return |
| 71 | + | return nil |
71 | 72 | | default: |
72 | | - | time.Sleep(1 * time.Second) |
| 73 | + | return fmt.Errorf("cannot load %s, channel is full", sock) |
73 | 74 | | } |
74 | 75 | | } |
75 | 76 | | } |
| skipped 10 lines |
86 | 87 | | var count int |
87 | 88 | | scan := bufio.NewScanner(strings.NewReader(socks)) |
88 | 89 | | for scan.Scan() { |
89 | | - | if p5.LoadSingleProxy(scan.Text()) { |
90 | | - | count++ |
| 90 | + | if err := p5.loadSingleProxy(scan.Text()); err != nil { |
| 91 | + | continue |
91 | 92 | | } |
| 93 | + | count++ |
92 | 94 | | } |
93 | 95 | | return count |
94 | 96 | | } |
| skipped 7 lines |