mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-17 02:20:27 +08:00
修复HTTP/3下无法传递ServerAddr的问题
This commit is contained in:
@@ -1430,11 +1430,25 @@ func (this *HTTPRequest) requestScheme() string {
|
|||||||
|
|
||||||
// 请求的服务器地址中的端口
|
// 请求的服务器地址中的端口
|
||||||
func (this *HTTPRequest) requestServerPort() int {
|
func (this *HTTPRequest) requestServerPort() int {
|
||||||
_, port, err := net.SplitHostPort(this.ServerAddr)
|
if len(this.ServerAddr) > 0 {
|
||||||
if err == nil {
|
_, port, err := net.SplitHostPort(this.ServerAddr)
|
||||||
return types.Int(port)
|
if err == nil && len(port) > 0 {
|
||||||
|
return types.Int(port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0
|
|
||||||
|
var host = this.RawReq.Host
|
||||||
|
if len(host) > 0 {
|
||||||
|
_, port, err := net.SplitHostPort(host)
|
||||||
|
if err == nil && len(port) > 0 {
|
||||||
|
return types.Int(port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if this.IsHTTP {
|
||||||
|
return 80
|
||||||
|
}
|
||||||
|
return 443
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *HTTPRequest) Id() string {
|
func (this *HTTPRequest) Id() string {
|
||||||
|
|||||||
@@ -105,8 +105,13 @@ func (this *HTTPListener) Reload(group *serverconfigs.ServerAddressGroup) {
|
|||||||
this.Reset()
|
this.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerHTTP 处理HTTP请求
|
// ServeHTTPWithAddr 处理HTTP请求
|
||||||
func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) {
|
func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) {
|
||||||
|
this.ServeHTTPWithAddr(rawWriter, rawReq, this.addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServeHTTPWithAddr 处理HTTP请求并指定服务地址
|
||||||
|
func (this *HTTPListener) ServeHTTPWithAddr(rawWriter http.ResponseWriter, rawReq *http.Request, serverAddr string) {
|
||||||
if len(rawReq.Host) > 253 {
|
if len(rawReq.Host) > 253 {
|
||||||
http.Error(rawWriter, "Host too long.", http.StatusBadRequest)
|
http.Error(rawWriter, "Host too long.", http.StatusBadRequest)
|
||||||
time.Sleep(1 * time.Second) // make connection slow down
|
time.Sleep(1 * time.Second) // make connection slow down
|
||||||
@@ -211,7 +216,7 @@ func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.
|
|||||||
ReqServer: server,
|
ReqServer: server,
|
||||||
ReqHost: reqHost,
|
ReqHost: reqHost,
|
||||||
ServerName: serverName,
|
ServerName: serverName,
|
||||||
ServerAddr: this.addr,
|
ServerAddr: serverAddr,
|
||||||
IsHTTP: this.isHTTP,
|
IsHTTP: this.isHTTP,
|
||||||
IsHTTPS: this.isHTTPS,
|
IsHTTPS: this.isHTTPS,
|
||||||
IsHTTP3: this.isHTTP3,
|
IsHTTP3: this.isHTTP3,
|
||||||
|
|||||||
Reference in New Issue
Block a user