From d6b3e0d910e1ae5cdbfc5d80828597b0af29fe7e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 5 Nov 2019 01:03:23 -0500 Subject: [PATCH] can skip some rsa work if we know we don't care about the result --- web.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/web.go b/web.go index 49b744a..801ee40 100644 --- a/web.go +++ b/web.go @@ -305,9 +305,19 @@ func inbox(w http.ResponseWriter, r *http.Request) { io.WriteString(os.Stdout, "\n") return } + if crappola(j) { return } + what, _ := j.GetString("type") + if what == "Like" { + return + } + who, _ := j.GetString("actor") + if rejectactor(user.ID, who) { + return + } + keyname, err := httpsig.VerifyRequest(r, payload, zaggy) if err != nil { log.Printf("inbox message failed signature for %s from %s", keyname, r.Header.Get("X-Forwarded-For")) @@ -320,19 +330,12 @@ func inbox(w http.ResponseWriter, r *http.Request) { http.Error(w, "what did you call me?", http.StatusTeapot) return } - what, _ := j.GetString("type") - if what == "Like" { - return - } - who, _ := j.GetString("actor") origin := keymatch(keyname, who) if origin == "" { log.Printf("keyname actor mismatch: %s <> %s", keyname, who) return } - if rejectactor(user.ID, who) { - return - } + switch what { case "Ping": obj, _ := j.GetString("id")