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) {
|
switch tbuf := buf.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
||||||
for _, curlinfo := range parseCurl(tbuf) {
|
for _, curlinfo := range parseCurl(tbuf) {
|
||||||
*curls = append(*curls, curlinfo)
|
*curls = append(*curls, curlinfo)
|
||||||
}
|
}
|
||||||
|
@ -184,6 +185,8 @@ func parseCurl(curl string) []string {
|
||||||
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
||||||
result = append(result, strings.Trim(curlinfo, "\r\n "))
|
result = append(result, strings.Trim(curlinfo, "\r\n "))
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
result = append(result, strings.Trim(curl, "\r\n "))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
45
person.go
45
person.go
|
@ -81,7 +81,6 @@ func NewPersonWithConfig(conf string) *Person {
|
||||||
func splitTasks(conf *Config) []ITask {
|
func splitTasks(conf *Config) []ITask {
|
||||||
var tasks []ITask
|
var tasks []ITask
|
||||||
proxies := (*clinked.CircularLinked)(conf.Proxies)
|
proxies := (*clinked.CircularLinked)(conf.Proxies)
|
||||||
|
|
||||||
for _, scurl := range conf.Curls {
|
for _, scurl := range conf.Curls {
|
||||||
curl, err := curl2info.ParseRawCURL(scurl)
|
curl, err := curl2info.ParseRawCURL(scurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -95,31 +94,33 @@ func splitTasks(conf *Config) []ITask {
|
||||||
switch conf.Mode {
|
switch conf.Mode {
|
||||||
case 0:
|
case 0:
|
||||||
initTask(conf, task, curl)
|
initTask(conf, task, curl)
|
||||||
for _, cnode := range proxies.GetLoopValues() {
|
if proxies != nil {
|
||||||
proxy := cnode.GetValue().(string)
|
for _, cnode := range proxies.GetLoopValues() {
|
||||||
log.Println(proxy)
|
proxy := cnode.GetValue().(string)
|
||||||
task.AddProxies(proxy)
|
task.AddProxies(proxy)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.Println(task.GetProxies())
|
|
||||||
tasks = append(tasks, task)
|
tasks = append(tasks, task)
|
||||||
case 1:
|
case 1:
|
||||||
|
if proxies != nil {
|
||||||
|
for _, cnode := range proxies.GetLoopValues() {
|
||||||
|
proxy := cnode.GetValue().(string)
|
||||||
|
|
||||||
for _, cnode := range proxies.GetLoopValues() {
|
ncurl, err := curl2info.ParseRawCURL(scurl)
|
||||||
proxy := cnode.GetValue().(string)
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
ncurl, err := curl2info.ParseRawCURL(scurl)
|
if curl.ITask == "" {
|
||||||
if err != nil {
|
curl.ITask = conf.ITask
|
||||||
panic(err)
|
}
|
||||||
|
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)
|
taskLen := len(person.Tasks)
|
||||||
|
|
||||||
result := make(chan string, 1)
|
result := make(chan string, 1)
|
||||||
|
log.Println(person.Tasks)
|
||||||
for _, task := range person.Tasks {
|
for _, task := range person.Tasks {
|
||||||
|
|
||||||
go ExecuteOnPlan(task, result)
|
go ExecuteOnPlan(task, result)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for t := range result {
|
for t := range result {
|
||||||
log.Println(t)
|
log.Println(t)
|
||||||
taskLen--
|
taskLen--
|
||||||
|
|
||||||
if taskLen <= 0 {
|
if taskLen <= 0 {
|
||||||
close(result)
|
close(result)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user