all repos — honk @ 1ba9361df84d65ad0ca13f08f52703c795bd4cdd

my fork of honk

simplify the request actor user agent stuff
Ted Unangst tedu@tedunangst.com
Sun, 24 Dec 2023 14:28:45 -0500
commit

1ba9361df84d65ad0ca13f08f52703c795bd4cdd

parent

7244bbc70cbe5a9db15ef1eda6a00d374f23fc99

2 files changed, 10 insertions(+), 10 deletions(-)

jump to
M hfcs.gohfcs.go

@@ -297,8 +297,7 @@ return !knowns[actor]

} func stealthmode(userid int64, r *http.Request) bool { - agent := r.UserAgent() - agent = originate(agent) + agent := requestActor(r) if agent != "" { fake := rejectorigin(userid, agent, false) if fake {
M web.goweb.go

@@ -1078,16 +1078,17 @@ }

var re_keyholder = regexp.MustCompile(`keyId="([^"]+)"`) -func trackback(xid string, r *http.Request) { - agent := r.UserAgent() - who := originate(agent) - sig := r.Header.Get("Signature") - if sig != "" { - m := re_keyholder.FindStringSubmatch(sig) - if len(m) == 2 { - who = m[1] +func requestActor(r *http.Request) string { + if sig := r.Header.Get("Signature"); sig != "" { + if m := re_keyholder.FindStringSubmatch(sig); len(m) == 2 { + return m[1] } } + return "" +} + +func trackback(xid string, r *http.Request) { + who := requestActor(r) if who != "" { trackchan <- Track{xid: xid, who: who} }