all repos — honk @ d5b65b6da3a25e970dbdd865b07be13fe9d3f6be

my fork of honk

rework stealth mode
Ted Unangst tedu@tedunangst.com
Sat, 21 Sep 2019 18:20:50 -0400
commit

d5b65b6da3a25e970dbdd865b07be13fe9d3f6be

parent

83ca3f088368feb9c5f5cbdbc8b9e86d0362fe5f

3 files changed, 21 insertions(+), 15 deletions(-)

jump to
M fun.gofun.go

@@ -461,7 +461,7 @@ return s

} var re_unurl = regexp.MustCompile("https://([^/]+).*/([^/]+)") -var re_urlhost = regexp.MustCompile("https://([^/]+)") +var re_urlhost = regexp.MustCompile("https://([^/ ]+)") func originate(u string) string { m := re_urlhost.FindStringSubmatch(u)

@@ -742,6 +742,20 @@ }

} } return false +} + +func stealthmode(userid int64, r *http.Request) bool { + agent := r.UserAgent() + agent = originate(agent) + addr := r.Header.Get("X-Forwarded-For") + thumblock.Lock() + biters := thumbbiters[userid] + thumblock.Unlock() + fake := (agent != "" && biters[agent]) || (addr != "" && biters[addr]) + if fake { + log.Printf("faking 404 for %s from %s", agent, addr) + } + return fake } func keymatch(keyname string, actor string) string {
M honk.gohonk.go

@@ -131,7 +131,6 @@ getconfig("servermsg", &serverMsg)

getconfig("servername", &serverName) getconfig("usersep", &userSep) getconfig("honksep", &honkSep) - getconfig("dnf", &donotfedafterdark) prepareStatements(db) switch cmd { case "adduser":
M web.goweb.go

@@ -48,17 +48,6 @@

var userSep = "u" var honkSep = "h" -var donotfedafterdark = make(map[string]bool) - -func stealthed(r *http.Request) bool { - addr := r.Header.Get("X-Forwarded-For") - fake := donotfedafterdark[addr] - if fake { - log.Printf("faking 404 for %s", addr) - } - return fake -} - func getuserstyle(u *login.UserInfo) template.CSS { if u == nil { return ""

@@ -438,7 +427,7 @@ if err != nil {

http.NotFound(w, r) return } - if stealthed(r) { + if stealthmode(user.ID, r) { http.NotFound(w, r) return }

@@ -492,6 +481,10 @@ name := mux.Vars(r)["name"]

user, err := butwhatabout(name) if err != nil { log.Printf("user not found %s: %s", name, err) + http.NotFound(w, r) + return + } + if stealthmode(user.ID, r) { http.NotFound(w, r) return }

@@ -616,7 +609,7 @@ if err != nil {

http.NotFound(w, r) return } - if stealthed(r) { + if stealthmode(user.ID, r) { http.NotFound(w, r) return }