1
0
mirror of https://github.com/dutchcoders/transfer.sh.git synced 2020-11-18 19:53:40 -08:00

updated redirect handling for domains and https defaults

This commit is contained in:
Remco 2014-11-11 15:34:03 +01:00
parent 1ecaf94d6d
commit c6af437480

View File

@ -506,13 +506,22 @@ func getHandler(w http.ResponseWriter, r *http.Request) {
func RedirectHandler(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if ipAddrFromRemoteAddr(r.Host) != "transfer.sh" && ipAddrFromRemoteAddr(r.Host) != "127.0.0.1" && r.URL.Path != "/health.html" {
http.Redirect(w, r, "https://transfer.sh/", 301)
if r.URL.Path == "/health.html" {
} else if ipAddrFromRemoteAddr(r.Host) == "127.0.0.1" {
} else if ipAddrFromRemoteAddr(r.Host) == "transfersh.elasticbeanstalk.com" {
} else if ipAddrFromRemoteAddr(r.Host) == "jxm5d6emw5rknovg.onion" {
if r.Header.Get("X-Forwarded-Proto") != "https" && r.Method == "GET" {
http.Redirect(w, r, "https://jxm5d6emw5rknovg.onion"+r.RequestURI, 301)
return
}
if ipAddrFromRemoteAddr(r.Host) == "transfer.sh" && r.Header.Get("X-Forwarded-Proto") != "https" && r.Method == "GET" {
http.Redirect(w, r, "https://transfer.sh/", 301)
} else if ipAddrFromRemoteAddr(r.Host) == "transfer.sh" {
if r.Header.Get("X-Forwarded-Proto") != "https" && r.Method == "GET" {
http.Redirect(w, r, "https://transfer.sh"+r.RequestURI, 301)
return
}
} else if ipAddrFromRemoteAddr(r.Host) != "transfer.sh" {
http.Redirect(w, r, "https://transfer.sh"+r.RequestURI, 301)
return
}