rework stealth mode
This commit is contained in:
parent
d97d815dae
commit
6ea1f7bfa0
16
fun.go
16
fun.go
|
@ -461,7 +461,7 @@ func ontologize(s string) string {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -744,6 +744,20 @@ func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
|||
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 {
|
||||
hash := strings.IndexByte(keyname, '#')
|
||||
if hash == -1 {
|
||||
|
|
1
honk.go
1
honk.go
|
@ -131,7 +131,6 @@ func main() {
|
|||
getconfig("servername", &serverName)
|
||||
getconfig("usersep", &userSep)
|
||||
getconfig("honksep", &honkSep)
|
||||
getconfig("dnf", &donotfedafterdark)
|
||||
prepareStatements(db)
|
||||
switch cmd {
|
||||
case "adduser":
|
||||
|
|
19
web.go
19
web.go
|
@ -48,17 +48,6 @@ var readviews *templates.Template
|
|||
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 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
|||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if stealthed(r) {
|
||||
if stealthmode(user.ID, r) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -495,6 +484,10 @@ func showuser(w http.ResponseWriter, r *http.Request) {
|
|||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if stealthmode(user.ID, r) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if friendorfoe(r.Header.Get("Accept")) {
|
||||
j := asjonker(user)
|
||||
w.Header().Set("Content-Type", theonetruename)
|
||||
|
@ -616,7 +609,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
|||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if stealthed(r) {
|
||||
if stealthmode(user.ID, r) {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue