37 lines
735 B
Go
37 lines
735 B
Go
package app
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/zu1k/proxypool/config"
|
|
"github.com/zu1k/proxypool/pkg/getter"
|
|
)
|
|
|
|
var Getters = make([]getter.Getter, 0)
|
|
|
|
func InitConfigAndGetters(path string) (err error) {
|
|
err = config.Parse(path)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if s := config.Config.Sources; len(s) == 0 {
|
|
return errors.New("no sources")
|
|
} else {
|
|
initGetters(s)
|
|
}
|
|
return
|
|
}
|
|
|
|
func initGetters(sources []config.Source) {
|
|
Getters = make([]getter.Getter, 0)
|
|
for _, source := range sources {
|
|
g, err := getter.NewGetter(source.Type, source.Options)
|
|
if err == nil && g != nil {
|
|
Getters = append(Getters, g)
|
|
fmt.Println("init getter:", source.Type, source.Options)
|
|
}
|
|
}
|
|
fmt.Println("Getter count:", len(Getters))
|
|
}
|