can skip some rsa work if we know we don't care about the result

This commit is contained in:
Ted Unangst 2019-11-05 01:03:23 -05:00
parent bd4c2f1114
commit d6b3e0d910
1 changed files with 11 additions and 8 deletions

19
web.go
View File

@ -305,9 +305,19 @@ func inbox(w http.ResponseWriter, r *http.Request) {
io.WriteString(os.Stdout, "\n") io.WriteString(os.Stdout, "\n")
return return
} }
if crappola(j) { if crappola(j) {
return 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) keyname, err := httpsig.VerifyRequest(r, payload, zaggy)
if err != nil { if err != nil {
log.Printf("inbox message failed signature for %s from %s", keyname, r.Header.Get("X-Forwarded-For")) 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) http.Error(w, "what did you call me?", http.StatusTeapot)
return return
} }
what, _ := j.GetString("type")
if what == "Like" {
return
}
who, _ := j.GetString("actor")
origin := keymatch(keyname, who) origin := keymatch(keyname, who)
if origin == "" { if origin == "" {
log.Printf("keyname actor mismatch: %s <> %s", keyname, who) log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
return return
} }
if rejectactor(user.ID, who) {
return
}
switch what { switch what {
case "Ping": case "Ping":
obj, _ := j.GetString("id") obj, _ := j.GetString("id")