mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-09 18:05:49 +08:00
URL跳转增加匹配前缀和是否保留RequestURI选项
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package nodes
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 主机地址快速跳转
|
||||
func (this *HTTPRequest) doHostRedirect() (blocked bool) {
|
||||
@@ -9,13 +12,28 @@ func (this *HTTPRequest) doHostRedirect() (blocked bool) {
|
||||
if !u.IsOn {
|
||||
continue
|
||||
}
|
||||
if fullURL == u.RealBeforeURL() {
|
||||
if u.Status <= 0 {
|
||||
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, u.Status)
|
||||
if u.MatchPrefix {
|
||||
if strings.HasPrefix(fullURL, u.BeforeURL) {
|
||||
afterURL := u.AfterURL
|
||||
if u.KeepRequestURI {
|
||||
afterURL += this.RawReq.URL.RequestURI()
|
||||
}
|
||||
if u.Status <= 0 {
|
||||
http.Redirect(this.RawWriter, this.RawReq, afterURL, http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
http.Redirect(this.RawWriter, this.RawReq, afterURL, u.Status)
|
||||
}
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
if fullURL == u.RealBeforeURL() {
|
||||
if u.Status <= 0 {
|
||||
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
http.Redirect(this.RawWriter, this.RawReq, u.AfterURL, u.Status)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user