no 404, instead 3xx redirect to onion

This commit is contained in:
Dan Ballard 2022-12-30 15:31:19 -08:00
parent 7ca5f77545
commit 2b102d8051
1 changed files with 7 additions and 5 deletions

12
main.go
View File

@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
//"fmt"
"git.openprivacy.ca/openprivacy/log"
"io/ioutil"
"net/http"
@ -120,8 +120,9 @@ func filter(res http.ResponseWriter, req *http.Request, listenPort, proxyPort in
blocklistLock.Unlock()
if ok && blocked {
log.Debugln("blocked ip, 404ing")
res.WriteHeader(http.StatusNotFound)
fmt.Fprint(res, "404 - suspected botnet")
http.Redirect(res, req, "http://gitopcybr57ris5iuivfz62gdwe2qk5pinnt2wplpwzicaybw73stjqd.onion", http.StatusSeeOther)
//res.WriteHeader(http.StatusNotFound)
//fmt.Fprint(res, "404 - suspected botnet")
return
}
@ -176,8 +177,9 @@ func filter(res http.ResponseWriter, req *http.Request, listenPort, proxyPort in
blocklistedIps[ip] = true
}
blocklistLock.Unlock()
res.WriteHeader(http.StatusNotFound)
fmt.Fprint(res, "404 - suspected botnet")
http.Redirect(res, req, "http://gitopcybr57ris5iuivfz62gdwe2qk5pinnt2wplpwzicaybw73stjqd.onion", http.StatusSeeOther)
// res.WriteHeader(http.StatusNotFound)
//fmt.Fprint(res, "404 - suspected botnet")
}
// https://medium.com/@mlowicki/http-s-proxy-in-golang-in-less-than-100-lines-of-code-6a51c2f2c38c