From 2a65b8bce544b4643c3d012c158950bc2e1a1853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= <tothmiklostibor@gmail.com> Date: Sun, 25 Jun 2023 00:50:54 +0200 Subject: [PATCH] Smol fix --- main.go | 2 +- sendMeme.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c7306f0..d345bad 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func init() { } var conn *websocket.Conn -var connCh = make(chan interface{}, 5) +var connCh = make(chan interface{}, 500) var socket = "ws://127.0.0.1:8080/ws" func init() { diff --git a/sendMeme.go b/sendMeme.go index da1650e..9929927 100644 --- a/sendMeme.go +++ b/sendMeme.go @@ -7,6 +7,7 @@ import ( "math/rand" "net/http" "strings" + "time" ) var cache = make(map[string]bool) @@ -17,6 +18,15 @@ func submit(ip, pass string) ([]string, error) { } resp, e := http.Post(fmt.Sprintf("http://[%s]:8080/attempt", ip), "text/plain", strings.NewReader(pass+"\n")) + if e != nil { + time.Sleep(time.Second * time.Duration(rand.Intn(5))) + resp, e = http.Post(fmt.Sprintf("http://[%s]:8080/attempt", ip), "text/plain", strings.NewReader(pass+"\n")) + if e != nil { + time.Sleep(time.Second * time.Duration(rand.Intn(5))) + resp, e = http.Post(fmt.Sprintf("http://[%s]:8080/attempt", ip), "text/plain", strings.NewReader(pass+"\n")) + } + } + if e != nil { log.Println("host is ded", ip) return nil, e @@ -56,6 +66,7 @@ func submit(ip, pass string) ([]string, error) { Id: rand.Int(), IPs: ips, } + defer resp.Body.Close() return ips, e } -- GitLab