zenbook migration
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module ddosbot
|
||||
|
||||
go 1.25.3
|
||||
@@ -0,0 +1,95 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Read URLs from environment variable
|
||||
urlsEnv := os.Getenv("TARGET_URLS")
|
||||
if urlsEnv == "" {
|
||||
log.Fatal("TARGET_URLS environment variable is not set")
|
||||
}
|
||||
|
||||
// Parse comma-delimited URLs
|
||||
urls := strings.Split(urlsEnv, ",")
|
||||
for i := range urls {
|
||||
urls[i] = strings.TrimSpace(urls[i])
|
||||
}
|
||||
|
||||
if len(urls) == 0 {
|
||||
log.Fatal("No URLs provided")
|
||||
}
|
||||
|
||||
fmt.Printf("Starting load test on %d URLs\n", len(urls))
|
||||
fmt.Println("URLs:", urls)
|
||||
fmt.Println("Press Ctrl+C to stop\n")
|
||||
|
||||
// Counters
|
||||
var (
|
||||
totalRequests uint64
|
||||
successCount uint64
|
||||
errorCount uint64
|
||||
)
|
||||
|
||||
// WaitGroup to track all goroutines
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Start time
|
||||
startTime := time.Now()
|
||||
|
||||
// Spawn a goroutine for each URL
|
||||
for _, url := range urls {
|
||||
wg.Add(1)
|
||||
go func(targetURL string) {
|
||||
defer wg.Done()
|
||||
|
||||
client := &http.Client{Timeout: time.Second}
|
||||
for {
|
||||
resp, err := client.Get(targetURL)
|
||||
atomic.AddUint64(&totalRequests, 1)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error: %s => %v\n", targetURL, err)
|
||||
atomic.AddUint64(&errorCount, 1)
|
||||
continue
|
||||
}
|
||||
|
||||
_ = resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
||||
atomic.AddUint64(&successCount, 1)
|
||||
} else {
|
||||
fmt.Printf("bad status: %s => %d\n", targetURL, resp.StatusCode)
|
||||
atomic.AddUint64(&errorCount, 1)
|
||||
}
|
||||
}
|
||||
}(url)
|
||||
}
|
||||
|
||||
// Progress reporter
|
||||
go func() {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
<-ticker.C
|
||||
elapsed := time.Since(startTime).Seconds()
|
||||
requests := atomic.LoadUint64(&totalRequests)
|
||||
success := atomic.LoadUint64(&successCount)
|
||||
errors := atomic.LoadUint64(&errorCount)
|
||||
fmt.Printf("Elapsed: %.0fs | Requests: %d | Success: %d | Errors: %d | Rate: %.0f req/s\n",
|
||||
elapsed, requests, success, errors, float64(requests)/elapsed)
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for all goroutines (runs forever until killed)
|
||||
wg.Wait()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
- hostname: ddosbot
|
||||
zeropsSetup: ddosbot
|
||||
type: go@1
|
||||
minContainers: 10
|
||||
@@ -0,0 +1,18 @@
|
||||
zerops:
|
||||
- setup: ddosbot
|
||||
build:
|
||||
os: alpine
|
||||
base: go@latest
|
||||
buildCommands:
|
||||
- go build main.go
|
||||
deployFiles:
|
||||
- main
|
||||
cache: true
|
||||
run:
|
||||
os: alpine
|
||||
base: alpine@latest
|
||||
envVariables:
|
||||
TARGET_URLS: https://api-e5-8080.app-tor1.zerops.dev,https://api-e0-8080.app-tor1.zerops.dev,https://api-f2-8080.app-tor1.zerops.dev,https://api-f5-8080.app-tor1.zerops.dev,https://api-da-8080.app-tor1.zerops.dev,https://tor1.saidl.info,https://api-ee-8080.app-tor1.zerops.dev,https://api-ec-8080.app-tor1.zerops.dev,https://api-e1-8080.app-tor1.zerops.dev,https://api-e7-8080.app-tor1.zerops.dev,https://api-e4-8080.app-tor1.zerops.dev,https://api-e3-8080.app-tor1.zerops.dev,https://tor1a.saidl.info,https://api-d9-8080.app-tor1.zerops.dev,https://api-e2-8080.app-tor1.zerops.dev,https://api-e6-8080.app-tor1.zerops.dev,https://api-f0-8080.app-tor1.zerops.dev,https://api-d8-8080.app-tor1.zerops.dev,https://api-e9-8080.app-tor1.zerops.dev,https://api-e8-8080.app-tor1.zerops.dev
|
||||
start: ./main
|
||||
|
||||
|
||||
Reference in New Issue
Block a user