Beispiel #1
0
func handleFlood(w http.ResponseWriter, req *http.Request) {
	s := req.FormValue("s")
	if s != "" {
		handleTimeFlood(w, req)
		return
	}

	ms := req.FormValue("m")
	if ms == "" {
		ms = "1"
	}
	m, err := strconv.ParseUint(ms, 10, 0)
	if err != nil {
		m = 1
	}
	w.Header().Set("Content-length", strconv.FormatUint(m*consts.Megabyte, 10))
	log.Printf("flood starting addr=%s megabytes=%d\n", extractIP(req.RemoteAddr), m)
	floodHelper(w, req, randomreader.LimitedRandomGen(m*consts.Megabyte))
}
Beispiel #2
0
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)
}
Beispiel #3
0
func sizeLimited(megabytes uint64) {
	sl := randomreader.LimitedRandomGen(megabytes * consts.Megabyte)
	testHelper(sl)
}