send index.html if auth didnt succeed as well

This commit is contained in:
b1ek 2024-07-26 16:58:46 +10:00
parent ca0ddaa076
commit 403549ed26
1 changed files with 4 additions and 0 deletions

View File

@ -89,6 +89,10 @@ func requireBasicAuth(wr http.ResponseWriter, req *http.Request, hidden_domain s
subtle.ConstantTimeCompare([]byte(req.Host), []byte(hidden_domain)) != 1) {
http.Error(wr, BAD_REQ_MSG, http.StatusBadRequest)
} else {
if req.Host == "astra.blek.codes" && req.URL.Host == "astra.blek.codes" && req.URL.Path == "/" {
SendIndex(wr, req)
return
}
wr.Header().Set("Proxy-Authenticate", `Basic realm="dumbproxy"`)
wr.Header().Set("Content-Length", strconv.Itoa(len([]byte(AUTH_REQUIRED_MSG))))
wr.WriteHeader(407)