mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-06 18:10:26 +08:00
在严格匹配域名模式下仍然可以通过节点IP进行健康检查
This commit is contained in:
@@ -3,6 +3,7 @@ package nodes
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/zero"
|
"github.com/TeaOSLab/EdgeNode/internal/zero"
|
||||||
@@ -170,8 +171,19 @@ func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.
|
|||||||
|
|
||||||
server, serverName := this.findNamedServer(domain)
|
server, serverName := this.findNamedServer(domain)
|
||||||
if server == nil {
|
if server == nil {
|
||||||
server = this.findServerWithCNAME(domain)
|
|
||||||
if server == nil {
|
if server == nil {
|
||||||
|
// TODO 需要记录访问记录和防止CC
|
||||||
|
|
||||||
|
// 是否为健康检查
|
||||||
|
var healthCheckKey = rawReq.Header.Get(serverconfigs.HealthCheckHeaderName)
|
||||||
|
if len(healthCheckKey) > 0 {
|
||||||
|
_, err := nodeutils.Base64DecodeMap(healthCheckKey)
|
||||||
|
if err == nil {
|
||||||
|
rawWriter.WriteHeader(http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 严格匹配域名模式下,我们拒绝用户访问
|
// 严格匹配域名模式下,我们拒绝用户访问
|
||||||
if sharedNodeConfig.GlobalConfig != nil && sharedNodeConfig.GlobalConfig.HTTPAll.MatchDomainStrictly {
|
if sharedNodeConfig.GlobalConfig != nil && sharedNodeConfig.GlobalConfig.HTTPAll.MatchDomainStrictly {
|
||||||
httpAllConfig := sharedNodeConfig.GlobalConfig.HTTPAll
|
httpAllConfig := sharedNodeConfig.GlobalConfig.HTTPAll
|
||||||
@@ -205,7 +217,7 @@ func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 包装新请求对象
|
// 包装新请求对象
|
||||||
req := &HTTPRequest{
|
var req = &HTTPRequest{
|
||||||
RawReq: rawReq,
|
RawReq: rawReq,
|
||||||
RawWriter: rawWriter,
|
RawWriter: rawWriter,
|
||||||
ReqServer: server,
|
ReqServer: server,
|
||||||
|
|||||||
Reference in New Issue
Block a user