func handleTimeFlood(w http.ResponseWriter, req *http.Request) { ss := req.FormValue("s") if ss == "" { ss = "10" } s, err := strconv.ParseUint(ss, 10, 0) if err != nil { s = 10 } log.Printf("flood starting addr=%s seconds=%d\n", extractIP(req.RemoteAddr), s) floodHelper(w, req, randomreader.TimedRandomGen(s)) }
func upload(host string, megs uint64, seconds uint64) { url := fmt.Sprintf("http://%s/upload", host) var reader io.Reader if seconds != 0 { reader = randomreader.TimedRandomGen(seconds) } else { reader = randomreader.LimitedRandomGen(megs * consts.Megabyte) } resp, err := http.Post(url, "application/octet-stream", reader) if err != nil { log.Fatal(err) } body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatal(err) } log.Printf("%s", body) }
func timeLimited(seconds uint64) { tl := randomreader.TimedRandomGen(seconds) testHelper(tl) }