健康检查支持UserAgent和是否基础请求设置

This commit is contained in:
GoEdgeLab
2021-10-19 16:31:27 +08:00
parent 8a267175d9
commit b63efeffa1
2 changed files with 35 additions and 0 deletions

View File

@@ -177,6 +177,14 @@ func (this *HTTPRequest) doBegin() {
} }
} }
// 处理健康检查
var healthCheckKey = this.RawReq.Header.Get(serverconfigs.HealthCheckHeaderName)
if len(healthCheckKey) > 0 {
if this.doHealthCheck(healthCheckKey) {
return
}
}
// 统计 // 统计
if this.web.StatRef != nil && this.web.StatRef.IsOn { if this.web.StatRef != nil && this.web.StatRef.IsOn {
this.doStat() this.doStat()

View File

@@ -0,0 +1,27 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package nodes
import (
"github.com/TeaOSLab/EdgeCommon/pkg/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
)
// 健康检查
func (this *HTTPRequest) doHealthCheck(key string) (stop bool) {
this.tags = append(this.tags, "healthCheck")
this.RawReq.Header.Del(serverconfigs.HealthCheckHeaderName)
data, err := nodeutils.DecryptData(sharedNodeConfig.NodeId, sharedNodeConfig.Secret, key)
if err != nil {
remotelogs.Error("HTTP_REQUEST_HEALTH_CHECK", "decode key failed: "+err.Error())
return
}
if data.GetBool("onlyBasicRequest") {
return true
}
return
}