Compare commits

...
Author SHA1 Message Date
Ice3man 49974403f7 misc 2025-07-15 16:47:18 +05:30
Ice3man 7f0026b090 misc 2025-07-15 16:31:40 +05:30
2 changed files with 10 additions and 0 deletions

No files matched your search

+2
View File
@@ -2,6 +2,7 @@ package core
import (
"context"
"fmt"
"sync"
"sync/atomic"
@@ -132,6 +133,7 @@ func (e *Engine) executeTemplateSpray(ctx context.Context, templatesList []*temp
wg.Add()
go func(tpl *templates.Template) {
defer wg.Done()
fmt.Printf("[spray] executing template: %s\n", tpl.ID)
// All other request types are executed here
// Note: executeTemplateWithTargets creates goroutines and blocks
// given template is executed on all targets
+8
View File
@@ -2,6 +2,7 @@ package core
import (
"context"
"fmt"
"sync"
"sync/atomic"
@@ -78,8 +79,10 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
}
target.Iterate(func(scannedValue *contextargs.MetaInput) bool {
fmt.Printf("[iter] iterating target: %s %s\n", template.ID, scannedValue.Input)
select {
case <-ctx.Done():
fmt.Printf("[iter] ctx done: %s %s\n", template.ID, scannedValue.Input)
return false // exit
default:
}
@@ -108,6 +111,7 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
// Skip if the host has had errors
if e.executerOpts.HostErrorsCache != nil && e.executerOpts.HostErrorsCache.Check(e.executerOpts.ProtocolType.String(), contextargs.NewWithMetaInput(ctx, scannedValue)) {
fmt.Printf("[iter] host error: %s %s\n", template.ID, scannedValue.Input)
return true
}
@@ -116,6 +120,7 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
defer wg.Done()
defer cleanupInFlight(index)
if skip {
fmt.Printf("[iter] skip: %s %s\n", template.ID, value.Input)
return
}
@@ -128,6 +133,7 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
case types.WorkflowProtocol:
match = e.executeWorkflow(ctx, template.CompiledWorkflow)
default:
fmt.Printf("[iter] executing template: %s %s\n", template.ID, value.Input)
if e.Callback != nil {
if results, err := template.Executer.ExecuteWithResults(ctx); err == nil {
for _, result := range results {
@@ -139,7 +145,9 @@ func (e *Engine) executeTemplateWithTargets(ctx context.Context, template *templ
match, err = template.Executer.Execute(ctx)
}
}
fmt.Printf("[iter] match: %s %s %v\n", template.ID, value.Input, match)
if err != nil {
fmt.Printf("[iter] error: %s %s\n", template.ID, value.Input)
gologger.Warning().Msgf("[%s] Could not execute step on %s: %s\n", e.executerOpts.Colorizer.BrightBlue(template.ID), value.Input, err)
}
results.CompareAndSwap(false, match)