Skip to content

Commit 9cc7d54

Browse files
committed
健康检查支持IPv6
1 parent 05ce1d3 commit 9cc7d54

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/tasks/health_check_executor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
88
"github.com/TeaOSLab/EdgeAPI/internal/errors"
9+
"github.com/TeaOSLab/EdgeAPI/internal/utils"
910
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
1011
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
1112
"github.com/iwind/TeaGo/lists"
@@ -160,6 +161,11 @@ func (this *HealthCheckExecutor) Run() ([]*HealthCheckResult, error) {
160161

161162
// 检查单个节点
162163
func (this *HealthCheckExecutor) checkNode(healthCheckConfig *serverconfigs.HealthCheckConfig, result *HealthCheckResult) error {
164+
// 支持IPv6
165+
if utils.IsIPv6(result.NodeAddr) {
166+
result.NodeAddr = "[" + result.NodeAddr + "]"
167+
}
168+
163169
url := strings.ReplaceAll(healthCheckConfig.URL, "${host}", result.NodeAddr)
164170
req, err := http.NewRequest(http.MethodGet, url, nil)
165171
if err != nil {

0 commit comments

Comments
 (0)