File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "math/rand"
55
66 "github.com/fsnotify/fsnotify"
7+ "github.com/kitabisa/mubeng/pkg/helper"
78)
89
910// NextProxy will navigate the next proxy to use
@@ -23,6 +24,26 @@ func (p *ProxyManager) RandomProxy() string {
2324 return p .Proxies [rand .Intn (len (p .Proxies ))]
2425}
2526
27+ // Rotate proxy based on method
28+ //
29+ // Valid methods are "sequent" and "random", default return empty string.
30+ func (p * ProxyManager ) Rotate (method string ) string {
31+ var proxy string
32+
33+ switch method {
34+ case "sequent" :
35+ proxy = p .NextProxy ()
36+ case "random" :
37+ proxy = p .RandomProxy ()
38+ }
39+
40+ if proxy != "" {
41+ proxy = helper .EvalFunc (proxy )
42+ }
43+
44+ return proxy
45+ }
46+
2647// Watch proxy file from events
2748func (p * ProxyManager ) Watch () (* fsnotify.Watcher , error ) {
2849 watcher , err := fsnotify .NewWatcher ()
You can’t perform that action at this time.
0 commit comments