arnaucube
arnaucube/goDDOSPublic Self-hosted repository
goDDOS/v2/server/cli.go
v2/server/cli.goRaw
 1package main
 2
 3import (
 4	"bufio"
 5	"fmt"
 6	"os"
 7	"strconv"
 8	"strings"
 9)
10
11//validURL checks if an url is a valid url
12func validURL(url string) bool {
13	return true
14}
15func consoleInput() { //example: ddos http://web.com 4
16	newcommand := bufio.NewReader(os.Stdin)
17	for {
18		fmt.Print("enter new order ([target] [count]): ")
19		text, _ := newcommand.ReadString('\n')
20		text = strings.TrimSpace(text)
21		if text != "" {
22			fmt.Println("console input command: " + text)
23			t := strings.Split(text, " ")
24			count, err := strconv.Atoi(t[1])
25			if err != nil {
26				fmt.Println("[error]: count parameter must be an integer")
27				continue
28			}
29			if t[0] == "null" || t[0] == "none" {
30				t[0] = ""
31			}
32			if validURL(t[0]); count >= 0 {
33				currentOrder.Target = t[0]
34				currentOrder.Count = count
35				fmt.Println(currentOrder)
36			}
37		}
38	}
39}