fix config load curl string

This commit is contained in:
eson 2018-12-09 22:25:48 +08:00
parent 5019e46d08
commit 1283154f32
2 changed files with 28 additions and 20 deletions

View File

@ -27,6 +27,7 @@ func (curls *YamlCurls) UnmarshalYAML(unmarshal func(interface{}) error) error {
switch tbuf := buf.(type) {
case string:
for _, curlinfo := range parseCurl(tbuf) {
*curls = append(*curls, curlinfo)
}
@ -184,6 +185,8 @@ func parseCurl(curl string) []string {
for _, curlinfo := range strings.Split(string(curldata), "\n") {
result = append(result, strings.Trim(curlinfo, "\r\n "))
}
default:
result = append(result, strings.Trim(curl, "\r\n "))
}
return result

View File

@ -81,7 +81,6 @@ func NewPersonWithConfig(conf string) *Person {
func splitTasks(conf *Config) []ITask {
var tasks []ITask
proxies := (*clinked.CircularLinked)(conf.Proxies)
for _, scurl := range conf.Curls {
curl, err := curl2info.ParseRawCURL(scurl)
if err != nil {
@ -95,15 +94,16 @@ func splitTasks(conf *Config) []ITask {
switch conf.Mode {
case 0:
initTask(conf, task, curl)
if proxies != nil {
for _, cnode := range proxies.GetLoopValues() {
proxy := cnode.GetValue().(string)
log.Println(proxy)
task.AddProxies(proxy)
}
log.Println(task.GetProxies())
}
tasks = append(tasks, task)
case 1:
if proxies != nil {
for _, cnode := range proxies.GetLoopValues() {
proxy := cnode.GetValue().(string)
@ -123,6 +123,7 @@ func splitTasks(conf *Config) []ITask {
}
}
}
}
return tasks
}
@ -132,13 +133,17 @@ func (person *Person) Execute() {
taskLen := len(person.Tasks)
result := make(chan string, 1)
log.Println(person.Tasks)
for _, task := range person.Tasks {
go ExecuteOnPlan(task, result)
}
for t := range result {
log.Println(t)
taskLen--
if taskLen <= 0 {
close(result)
}