Skip to content

Commit

Permalink
added job specific logging
Browse files Browse the repository at this point in the history
  • Loading branch information
amivashko authored and arriven committed Mar 4, 2022
1 parent 67c7c16 commit 299eddb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,22 @@ func httpJob(ctx context.Context, l *logs.Logger, args JobArgs) error {
Timeout: timeout,
}
trafficMonitor := metrics.Default.NewWriter(ctx, "traffic", uuid.New().String())
ticker := time.NewTicker(time.Second)
defer ticker.Stop()

for jobConfig.Next(ctx) {
req, err := http.NewRequest(parseStringTemplate(jobConfig.Method), parseStringTemplate(jobConfig.Path), bytes.NewReader(parseByteTemplate(jobConfig.Body)))
if err != nil {
l.Debug("error creating request: %v", err)
continue
}

select {
case <-ticker.C:
l.Info("Attacking %v", jobConfig.Path)
default:
}

// Add random user agent
req.Header.Set("user-agent", uarand.GetRandom())
for key, value := range jobConfig.Headers {
Expand Down Expand Up @@ -476,9 +485,18 @@ func packetgenJob(ctx context.Context, l *logs.Logger, args JobArgs) error {
return err
}

ticker := time.NewTicker(time.Second)
defer ticker.Stop()

trafficMonitor := metrics.Default.NewWriter(ctx, "traffic", uuid.New().String())

for jobConfig.Next(ctx) {
select {
case <-ticker.C:
l.Info("Attacking %v:%v", jobConfig.Host, jobConfig.Port)
default:
}

packetConfigBytes := parseByteTemplate(jobConfig.Packet)
l.Debug("[packetgen] parsed packet config template:\n%s", string(packetConfigBytes))
var packetConfig packetgen.PacketConfig
Expand Down

0 comments on commit 299eddb

Please sign in to comment.