diff --git a/ip_lookups/IP2LOCATION-LITE-DB1.BIN b/ip_lookups/IP2LOCATION-LITE-DB1.BIN deleted file mode 100755 index 69dc7fe..0000000 Binary files a/ip_lookups/IP2LOCATION-LITE-DB1.BIN and /dev/null differ diff --git a/ip_lookups/IP2LOCATION-LITE-DB1.IPV6.BIN b/ip_lookups/IP2LOCATION-LITE-DB1.IPV6.BIN deleted file mode 100755 index a3baa0d..0000000 Binary files a/ip_lookups/IP2LOCATION-LITE-DB1.IPV6.BIN and /dev/null differ diff --git a/main.go b/main.go index d817ce9..1bf498d 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "encoding/json" "fmt" "log" @@ -70,7 +71,11 @@ func handler(w http.ResponseWriter, r *http.Request) { log.Println(err.Error()) return } - go sendWebhook("New report!") + err = sendWebhook("New report!") + if err != nil { + log.Println(err.Error()) + return + } } else if i.Event == "account.created" { var account MastodonSignUpEvent err := json.NewDecoder(r.Body).Decode(&account) @@ -79,7 +84,11 @@ func handler(w http.ResponseWriter, r *http.Request) { return } country := ipLookup(account.Object.IP) - go sendWebhook(fmt.Sprintf("*New Signup* %s has joined from %s", account.Object.Username, country)) + err = sendWebhook(fmt.Sprintf("*New Signup* %s has joined from %s", account.Object.Username, country)) + if err != nil { + log.Println(err.Error()) + return + } } } } @@ -96,7 +105,11 @@ func sendWebhook(msgText string) error { if err != nil { return err } - req, err := http.NewRequest("POST", MATRIX_WEBHOOK_URL+"/"+MATRIX_CHANNEL, b) + req, err := http.NewRequest("POST", MATRIX_WEBHOOK_URL+"/"+MATRIX_CHANNEL, bytes.NewBuffer(b)) + if err != nil { + return err + } + req.Header.Set("X-Custom-Header", "myvalue") req.Header.Set("Content-Type", "application/json")