File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -334,13 +334,14 @@ func DNSCaching(ttl time.Duration) func(*Attacker) {
334334 for i := 0 ; i < len (ips ) && j < 2 ; i ++ {
335335 ip := net .ParseIP (ips [i ])
336336 switch {
337- case len (ip . To4 ()) == net .IPv4len && j == 0 :
337+ case len (ip ) == net .IPv4len && ( j == 0 || len ( ips [ j - 1 ]) == net . IPv6len ) :
338338 fallthrough
339- case len (ip ) == net .IPv6len && j == 1 :
339+ case len (ip ) == net .IPv6len && ( j == 0 || len ( ips [ j - 1 ]) == net . IPv4len ) :
340340 ips [j ] = ips [i ]
341341 j ++
342342 }
343343 }
344+
344345 ips = ips [:j ]
345346
346347 type result struct {
Original file line number Diff line number Diff line change @@ -407,3 +407,16 @@ func TestVegetaHeaders(t *testing.T) {
407407 }
408408 }
409409}
410+
411+ // https://github.com/tsenart/vegeta/issues/649
412+ func TestDNSCaching_Issue649 (t * testing.T ) {
413+ defer func () {
414+ if err := recover (); err != nil {
415+ t .Fatalf ("panic: %v" , err )
416+ }
417+ }()
418+
419+ tr := NewStaticTargeter (Target {Method : "GET" , URL : "https://[2a00:1450:4005:802::200e]" })
420+ atk := NewAttacker (DNSCaching (0 ))
421+ _ = atk .hit (tr , & attack {name : "TEST" , began : time .Now ()})
422+ }
You can’t perform that action at this time.
0 commit comments