fix config load curl string
This commit is contained in:
parent
5019e46d08
commit
1283154f32
|
@ -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
|
||||
|
|
45
person.go
45
person.go
|
@ -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,31 +94,33 @@ func splitTasks(conf *Config) []ITask {
|
|||
switch conf.Mode {
|
||||
case 0:
|
||||
initTask(conf, task, curl)
|
||||
for _, cnode := range proxies.GetLoopValues() {
|
||||
proxy := cnode.GetValue().(string)
|
||||
log.Println(proxy)
|
||||
task.AddProxies(proxy)
|
||||
if proxies != nil {
|
||||
for _, cnode := range proxies.GetLoopValues() {
|
||||
proxy := cnode.GetValue().(string)
|
||||
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)
|
||||
|
||||
for _, cnode := range proxies.GetLoopValues() {
|
||||
proxy := cnode.GetValue().(string)
|
||||
ncurl, err := curl2info.ParseRawCURL(scurl)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ncurl, err := curl2info.ParseRawCURL(scurl)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if curl.ITask == "" {
|
||||
curl.ITask = conf.ITask
|
||||
}
|
||||
ptask := makeRegisterType(ncurl.ITask).(ITask)
|
||||
initTask(conf, ptask, ncurl)
|
||||
|
||||
ptask.AddProxies(proxy)
|
||||
tasks = append(tasks, ptask)
|
||||
}
|
||||
|
||||
if curl.ITask == "" {
|
||||
curl.ITask = conf.ITask
|
||||
}
|
||||
ptask := makeRegisterType(ncurl.ITask).(ITask)
|
||||
initTask(conf, ptask, ncurl)
|
||||
|
||||
ptask.AddProxies(proxy)
|
||||
tasks = append(tasks, ptask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user