Skip to content

Instantly share code, notes, and snippets.

@fionera
Last active October 26, 2020 16:21
Show Gist options
  • Save fionera/616a1e50a2388c8b8539663506845f5b to your computer and use it in GitHub Desktop.
Save fionera/616a1e50a2388c8b8539663506845f5b to your computer and use it in GitHub Desktop.
Goldene Henne Bot
package main
import (
"fmt"
"log"
"sync"
"sync/atomic"
"time"
"golang.org/x/net/websocket"
)
var origin = "https://voting.goldene-henne.de"
var url = "wss://mdr-pri-prod.peak-performance-apps.de/events/connect?transport=webSockets&clientProtocol=1.5&connectionToken=1LnRnqRFtnKnlA8SZjTXrP4XWb6Gs7z%2BUHARceTEDiNTCKInZIoG6LrfcZFPz1sJ87FNkUSWhH4Z34Ha%2BM6a4%2BaTJTa%2F07mUqnV%2BRnAdp%2BQBtKnr&tid=1"
var i uint64
func main() {
go func() {
for {
log.Println(atomic.SwapUint64(&i, 0))
time.Sleep(1 * time.Second)
}
}()
wg := sync.WaitGroup{}
for a := 0; a < 100; a++ {
wg.Add(1)
go spammer(&wg)
}
wg.Wait()
}
func spammer(wg *sync.WaitGroup) {
defer wg.Done()
ws, err := websocket.Dial(url, "", origin)
if err != nil {
log.Fatal(err)
}
go func() {
for {
var msg = make([]byte, 512)
_, err = ws.Read(msg)
if err != nil {
log.Println(err)
return
}
fmt.Printf("Receive: %s\n", msg)
}
}()
for {
message := []byte("BA==")
_, err = ws.Write(message)
if err != nil {
log.Println(err)
return
}
atomic.AddUint64(&i, 1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment