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:
parent
1ecaf94d6d
commit
c6af437480
@ -506,13 +506,22 @@ func getHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func RedirectHandler(h http.Handler) http.HandlerFunc {
|
func RedirectHandler(h http.Handler) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
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" {
|
if r.URL.Path == "/health.html" {
|
||||||
http.Redirect(w, r, "https://transfer.sh/", 301)
|
} else if ipAddrFromRemoteAddr(r.Host) == "127.0.0.1" {
|
||||||
return
|
} 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" {
|
||||||
|
|
||||||
if ipAddrFromRemoteAddr(r.Host) == "transfer.sh" && r.Header.Get("X-Forwarded-Proto") != "https" && r.Method == "GET" {
|
http.Redirect(w, r, "https://jxm5d6emw5rknovg.onion"+r.RequestURI, 301)
|
||||||
http.Redirect(w, r, "https://transfer.sh/", 301)
|
return
|
||||||
|
}
|
||||||
|
} 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user