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:
@@ -27,17 +27,17 @@ func (sys *System) FetchNetworkProbeResults() (map[string]probe.Result, error) {
|
||||
return results, err
|
||||
}
|
||||
|
||||
// hasEnabledProbes returns true if this system has any enabled network probes.
|
||||
func (sys *System) hasEnabledProbes() bool {
|
||||
count, err := sys.manager.hub.CountRecords("network_probes",
|
||||
dbx.NewExp("system = {:system} AND enabled = true", dbx.Params{"system": sys.Id}))
|
||||
return err == nil && count > 0
|
||||
}
|
||||
|
||||
// fetchAndSaveProbeResults fetches probe results and saves them to the database.
|
||||
func (sys *System) fetchAndSaveProbeResults() {
|
||||
hub := sys.manager.hub
|
||||
|
||||
// Check if this system has any probes
|
||||
count, err := hub.CountRecords("network_probes",
|
||||
dbx.NewExp("system = {:system} AND enabled = true", dbx.Params{"system": sys.Id}))
|
||||
if err != nil || count == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
results, err := sys.FetchNetworkProbeResults()
|
||||
if err != nil || len(results) == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user