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