This commit is contained in:
henrygd
2026-04-26 13:37:33 -04:00
parent 89ac8dc585
commit 0378023b6f
5 changed files with 94 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
package hub
import (
"strconv"
"time"
"github.com/henrygd/beszel/internal/entities/probe"
@@ -11,7 +12,7 @@ import (
// generateProbeID creates a stable hash ID for a probe based on its configuration and the system it belongs to.
func generateProbeID(systemId string, config probe.Config) string {
return systems.MakeStableHashId(systemId, config.Target, config.Protocol)
return systems.MakeStableHashId(systemId, config.Target, config.Protocol, strconv.FormatUint(uint64(config.Port), 10))
}
// bindNetworkProbesEvents keeps probe records and agent probe state in sync.

View File

@@ -23,7 +23,7 @@ func TestGenerateProbeID(t *testing.T) {
Port: 80,
Interval: 60,
},
expected: "a20a5827",
expected: "de7b3647",
},
{
name: "HTTP probe on example.com with different system ID",
@@ -34,7 +34,7 @@ func TestGenerateProbeID(t *testing.T) {
Port: 80,
Interval: 60,
},
expected: "ab602ae7",
expected: "be9e2707",
},
{
name: "Same probe, different interval",
@@ -45,7 +45,7 @@ func TestGenerateProbeID(t *testing.T) {
Port: 80,
Interval: 120,
},
expected: "ab602ae7",
expected: "be9e2707",
},
{
name: "ICMP probe on 1.1.1.1",
@@ -56,7 +56,7 @@ func TestGenerateProbeID(t *testing.T) {
Port: 0,
Interval: 10,
},
expected: "6d13a4a4",
expected: "49ec14fc",
}, {
name: "ICMP probe on 1.1.1.1 with different system ID",
systemID: "sys4567",
@@ -66,7 +66,29 @@ func TestGenerateProbeID(t *testing.T) {
Port: 0,
Interval: 10,
},
expected: "ddd6c81",
expected: "84921aa3",
},
{
name: "TCP probe on example.com with port 443",
systemID: "sys789",
config: probe.Config{
Protocol: "tcp",
Target: "example.com",
Port: 443,
Interval: 30,
},
expected: "677b991",
},
{
name: "TCP probe on example.com with port 8443",
systemID: "sys789",
config: probe.Config{
Protocol: "tcp",
Target: "example.com",
Port: 8443,
Interval: 30,
},
expected: "84167969",
},
}