修复task count算错误的bug

This commit is contained in:
M09Ic 2023-04-06 20:41:35 +08:00
parent 77b92b44ea
commit ccc9ca3719
2 changed files with 10 additions and 4 deletions

View File

@ -365,7 +365,10 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
if err != nil {
u, _ = url.Parse("http://" + opt.URL[0])
}
go opt.GenerateTasks(tasks, u.Hostname(), ports)
go func() {
opt.GenerateTasks(tasks, u.Hostname(), ports)
close(tasks)
}()
taskfrom = u.Host
r.Count = 1
} else if len(opt.URL) > 1 {
@ -446,7 +449,10 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
}
}
r.Count = r.Count * len(ports)
if len(ports) > 0 {
r.Count = r.Count * len(ports)
}
r.Tasks = tasks
logs.Log.Importantf("Loaded %d urls from %s", len(tasks), taskfrom)

View File

@ -155,8 +155,8 @@ func (r *Runner) Prepare(ctx context.Context) error {
close(r.taskCh)
}()
if len(r.Tasks) > 0 {
r.bar = r.Progress.AddBar(len(r.Tasks))
if r.Count > 0 {
r.bar = r.Progress.AddBar(r.Count)
r.bar.PrependCompleted()
r.bar.PrependFunc(func(b *uiprogress.Bar) string {
return fmt.Sprintf("total progressive: %d/%d ", r.finished, r.Count)