mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-27 01:50:30 +08:00
健康检查支持UserAgent和是否基础请求设置
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
27
internal/nodes/http_request_health_check.go
Normal file
27
internal/nodes/http_request_health_check.go
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user