fix: Enrollment-Duplikate, IPv6-Adresse, Agent-Status
- Backend: Enroll-Upsert via MAC-Adresse (kein Duplikat bei Neustart) HeartbeatInterval auf 30s reduziert - Go collector: IPv4 bevorzugen, Loopback/Teredo/ISATAP überspringen, Link-Local IPv6 ignorieren - Go main.go: Enrollment nimmt beste IPv4-Schnittstelle statt Networks[0]
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -40,10 +41,20 @@ func main() {
|
||||
if cfg.AgentID == "" {
|
||||
hostname, _ := os.Hostname()
|
||||
metrics, _ := collector.Collect()
|
||||
// Beste Netzwerkschnittstelle für Enrollment wählen (bevorzuge IPv4)
|
||||
mac, ip := "", ""
|
||||
if len(metrics.Networks) > 0 {
|
||||
mac = metrics.Networks[0].MAC
|
||||
ip = metrics.Networks[0].IPAddress
|
||||
for _, n := range metrics.Networks {
|
||||
if n.MAC == "" || n.IPAddress == "" {
|
||||
continue
|
||||
}
|
||||
if mac == "" {
|
||||
mac, ip = n.MAC, n.IPAddress
|
||||
}
|
||||
// Sobald IPv4 gefunden: nehmen und fertig
|
||||
if !strings.Contains(n.IPAddress, ":") {
|
||||
mac, ip = n.MAC, n.IPAddress
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := client.Client.Enroll(context.Background(), &pb.EnrollRequest{
|
||||
|
||||
Reference in New Issue
Block a user