Complete subnet immune autopsy UI and prefix normalization.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Normalize /24 labels for autopsy API and cred-graph triggers; add Emberwake/Path Tracer autopsy cards and Vitest coverage for Seer feed consumers.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package atlas
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"crypto-miner-server/internal/db"
|
||||
@@ -22,7 +23,18 @@ func NewSubnetImmune(database *db.Database) *SubnetImmune {
|
||||
|
||||
// PrefixFromHostOrIP normalizes a host IP or subnet label to a /24 prefix key.
|
||||
func PrefixFromHostOrIP(hostOrSubnet string) string {
|
||||
return SubnetPrefix(hostOrSubnet)
|
||||
s := strings.TrimSpace(hostOrSubnet)
|
||||
s = strings.TrimSuffix(s, ".x")
|
||||
s = strings.TrimSuffix(s, ".0/24")
|
||||
s = strings.TrimSuffix(s, "/24")
|
||||
if prefix := SubnetPrefix(s); prefix != "" {
|
||||
return prefix
|
||||
}
|
||||
parts := strings.Split(s, ".")
|
||||
if len(parts) >= 3 && parts[0] != "" && parts[1] != "" && parts[2] != "" {
|
||||
return strings.Join(parts[:3], ".")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// RecordSpreadFailure increments subnet failure count; returns true when pause activates.
|
||||
|
||||
@@ -42,4 +42,10 @@ func TestPrefixFromHostOrIP(t *testing.T) {
|
||||
if got := PrefixFromHostOrIP("172.16.5.9"); got != "172.16.5" {
|
||||
t.Fatalf("prefix=%q", got)
|
||||
}
|
||||
if got := PrefixFromHostOrIP("10.0.0.x"); got != "10.0.0" {
|
||||
t.Fatalf("label prefix=%q", got)
|
||||
}
|
||||
if got := PrefixFromHostOrIP("10.2.2"); got != "10.2.2" {
|
||||
t.Fatalf("bare prefix=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user