| skipped 6 lines |
7 | 7 | | ) |
8 | 8 | | |
9 | 9 | | // AddUserAgents appends to the list of useragents we randomly choose from during proxied requests |
10 | | - | func (pe *ProxyEngine) AddUserAgents(uagents []string) { |
| 10 | + | func (pe *Swamp) AddUserAgents(uagents []string) { |
11 | 11 | | pe.mu.Lock() |
12 | 12 | | defer pe.mu.Unlock() |
13 | 13 | | pe.swampopt.userAgents = append(pe.swampopt.userAgents, uagents...) |
14 | 14 | | } |
15 | 15 | | |
16 | 16 | | // SetUserAgents sets the list of useragents we randomly choose from during proxied requests |
17 | | - | func (pe *ProxyEngine) SetUserAgents(uagents []string) { |
| 17 | + | func (pe *Swamp) SetUserAgents(uagents []string) { |
18 | 18 | | pe.mu.Lock() |
19 | 19 | | defer pe.mu.Unlock() |
20 | 20 | | pe.swampopt.userAgents = uagents |
21 | 21 | | } |
22 | 22 | | |
23 | 23 | | // SetCheckEndpoints replaces the running list of whatismyip style endpoitns for validation. (must return only the WAN IP) |
24 | | - | func (pe *ProxyEngine) SetCheckEndpoints(newendpoints []string) { |
| 24 | + | func (pe *Swamp) SetCheckEndpoints(newendpoints []string) { |
25 | 25 | | pe.mu.Lock() |
26 | 26 | | defer pe.mu.Unlock() |
27 | 27 | | pe.swampopt.checkEndpoints = newendpoints |
28 | 28 | | } |
29 | 29 | | |
30 | 30 | | // AddCheckEndpoints appends entries to the running list of whatismyip style endpoitns for validation. (must return only the WAN IP) |
31 | | - | func (pe *ProxyEngine) AddCheckEndpoints(endpoints []string) { |
| 31 | + | func (pe *Swamp) AddCheckEndpoints(endpoints []string) { |
32 | 32 | | pe.mu.Lock() |
33 | 33 | | defer pe.mu.Unlock() |
34 | 34 | | pe.swampopt.checkEndpoints = append(pe.swampopt.checkEndpoints, endpoints...) |
35 | 35 | | } |
36 | 36 | | |
37 | 37 | | // SetStaleTime replaces the duration of time after which a proxy will be considered "stale". stale proxies will be skipped upon retrieval. |
38 | | - | func (pe *ProxyEngine) SetStaleTime(newtime time.Duration) { |
| 38 | + | func (pe *Swamp) SetStaleTime(newtime time.Duration) { |
39 | 39 | | pe.swampopt.Lock() |
40 | 40 | | defer pe.swampopt.Unlock() |
41 | 41 | | pe.swampopt.stale = newtime |
42 | 42 | | } |
43 | 43 | | |
44 | 44 | | // SetValidationTimeout sets the validationTimeout option. |
45 | | - | func (pe *ProxyEngine) SetValidationTimeout(timeout time.Duration) { |
| 45 | + | func (pe *Swamp) SetValidationTimeout(timeout time.Duration) { |
46 | 46 | | pe.swampopt.Lock() |
47 | 47 | | defer pe.swampopt.Unlock() |
48 | 48 | | pe.swampopt.validationTimeout = timeout |
| skipped 2 lines |
51 | 51 | | // SetServerTimeout sets the serverTimeout option. |
52 | 52 | | // * serverTimeout defines the timeout for outgoing connections made with the MysteryDialer. |
53 | 53 | | // * To disable timeout on outgoing MysteryDialer connections, set this to time.Duration(0). |
54 | | - | func (pe *ProxyEngine) SetServerTimeout(timeout time.Duration) { |
| 54 | + | func (pe *Swamp) SetServerTimeout(timeout time.Duration) { |
55 | 55 | | pe.swampopt.Lock() |
56 | 56 | | defer pe.swampopt.Unlock() |
57 | 57 | | pe.swampopt.serverTimeout = timeout |
58 | 58 | | } |
59 | 59 | | |
60 | 60 | | // SetMaxWorkers set the maximum workers for proxy checking and clears the current proxy map and worker pool jobs. |
61 | | - | func (pe *ProxyEngine) SetMaxWorkers(num int) { |
| 61 | + | func (pe *Swamp) SetMaxWorkers(num int) { |
62 | 62 | | pe.pool.Tune(num) |
63 | 63 | | } |
64 | 64 | | |
65 | 65 | | // EnableRecycling enables recycling used proxies back into the pending channel for revalidation after dispensed. |
66 | | - | func (pe *ProxyEngine) EnableRecycling() { |
| 66 | + | func (pe *Swamp) EnableRecycling() { |
67 | 67 | | pe.swampopt.Lock() |
68 | 68 | | defer pe.swampopt.Unlock() |
69 | 69 | | pe.swampopt.recycle = true |
70 | 70 | | } |
71 | 71 | | |
72 | 72 | | // DisableRecycling disables recycling used proxies back into the pending channel for revalidation after dispensed. |
73 | | - | func (pe *ProxyEngine) DisableRecycling() { |
| 73 | + | func (pe *Swamp) DisableRecycling() { |
74 | 74 | | pe.swampopt.Lock() |
75 | 75 | | defer pe.swampopt.Unlock() |
76 | 76 | | pe.swampopt.recycle = false |
| skipped 3 lines |
80 | 80 | | // - Default is 10 |
81 | 81 | | // - To disable deleting entirely, set this value to -1 |
82 | 82 | | // - Only applies when recycling is enabled |
83 | | - | func (pe *ProxyEngine) SetRemoveAfter(timesfailed int) { |
| 83 | + | func (pe *Swamp) SetRemoveAfter(timesfailed int) { |
84 | 84 | | pe.swampopt.Lock() |
85 | 85 | | defer pe.swampopt.Unlock() |
86 | 86 | | pe.swampopt.removeafter = timesfailed |
| skipped 1 lines |
88 | 88 | | |
89 | 89 | | // SetDialerBailout sets the amount of times the MysteryDialer will dial out and fail before it bails out. |
90 | 90 | | // - The dialer will attempt to redial a destination with a different proxy a specified amount of times before it gives up |
91 | | - | func (pe *ProxyEngine) SetDialerBailout(dialattempts int) { |
| 91 | + | func (pe *Swamp) SetDialerBailout(dialattempts int) { |
92 | 92 | | pe.swampopt.Lock() |
93 | 93 | | defer pe.swampopt.Unlock() |
94 | 94 | | pe.swampopt.dialerBailout = dialattempts |
| skipped 2 lines |
97 | 97 | | // SetDispenseMiddleware will add a function that sits within the dialing process of the MysteryDialer and anyhing using it. |
98 | 98 | | // This means this function will be called mid-dial during connections. Return true to approve proxy, false to skip it. |
99 | 99 | | // Take care modiying the proxy in-flight as it is a pointer. |
100 | | - | func (pe *ProxyEngine) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) { |
| 100 | + | func (pe *Swamp) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) { |
101 | 101 | | pe.mu.Lock() |
102 | 102 | | defer pe.mu.Unlock() |
103 | 103 | | pe.dispenseMiddleware = f |
104 | 104 | | } |
105 | 105 | | |
106 | | - | // SetDebugLogger sets the debug logger for the ProxyEngine. See the Logger interface for implementation details. |
107 | | - | func (pe *ProxyEngine) SetDebugLogger(l logger.Logger) { |
| 106 | + | // SetDebugLogger sets the debug logger for the Swamp. See the Logger interface for implementation details. |
| 107 | + | func (pe *Swamp) SetDebugLogger(l logger.Logger) { |
108 | 108 | | debugHardLock.Lock() |
109 | 109 | | pe.mu.Lock() |
110 | 110 | | pe.DebugLogger = l |
| skipped 1 lines |
112 | 112 | | debugHardLock.Unlock() |
113 | 113 | | } |
114 | 114 | | |
115 | | - | func (pe *ProxyEngine) SetShuffle(shuffle bool) { |
| 115 | + | func (pe *Swamp) SetShuffle(shuffle bool) { |
116 | 116 | | pe.mu.Lock() |
117 | 117 | | defer pe.mu.Unlock() |
118 | 118 | | pe.swampopt.shuffle = shuffle |
| skipped 2 lines |