Skip to content
Snippets Groups Projects
Verified Commit bf93f4c8 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

Fixes

parent a1897871
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ func Discover(d Discovered) error {
return
}
if det.Score < -10 {
if det.Score < 0 {
log.Println("Shitty host detected, baiting...")
e := tutter.SendIPs([]string{ip})
if e != nil {
......
......@@ -7,14 +7,18 @@ import (
"math/rand"
"net/http"
"strings"
"sync"
)
var mut sync.Mutex
var cache = make(map[string]bool)
func submit(ip, pass string) ([]string, error) {
mut.Lock()
if cache[ip] {
return nil, nil
}
mut.Unlock()
resp, e := http.Post(fmt.Sprintf("http://[%s]:8080/attempt", ip), "text/plain", strings.NewReader(pass+"\n"))
if e != nil {
......@@ -33,7 +37,9 @@ func submit(ip, pass string) ([]string, error) {
log.Println("They fucked up")
case 204:
fmt.Printf("First submission to %s\n", ip)
mut.Lock()
cache[ip] = true
mut.Unlock()
connCh <- Submitted{
Id: rand.Int(),
IP: ip,
......@@ -42,7 +48,9 @@ func submit(ip, pass string) ([]string, error) {
}
return nil, e
case 200:
mut.Lock()
cache[ip] = true
mut.Unlock()
var ips []string
dec := json.NewDecoder(resp.Body)
e = dec.Decode(&ips)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment