mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-21 04:01:50 +02:00
fix: address network probe code quality issues
- Use shared http.Client in ProbeManager to avoid connection/transport leak - Skip probe goroutine and agent request when system has no enabled probes - Validate HTTP probe target URL scheme (http:// or https://) on creation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package hub
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
@@ -75,6 +76,9 @@ func (h *Hub) createNetworkProbe(e *core.RequestEvent) error {
|
||||
if req.Protocol != "icmp" && req.Protocol != "tcp" && req.Protocol != "http" {
|
||||
return e.BadRequestError("protocol must be icmp, tcp, or http", nil)
|
||||
}
|
||||
if req.Protocol == "http" && !strings.HasPrefix(req.Target, "http://") && !strings.HasPrefix(req.Target, "https://") {
|
||||
return e.BadRequestError("http probe target must start with http:// or https://", nil)
|
||||
}
|
||||
if req.Interval <= 0 {
|
||||
req.Interval = 10
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user