From 990565b5564ca84317bf88b2a50fbbf2c3a46c50 Mon Sep 17 00:00:00 2001 From: jbergner Date: Sun, 2 Nov 2025 16:43:29 +0100 Subject: [PATCH] Added Logging --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 32f1121..3442dd3 100644 --- a/main.go +++ b/main.go @@ -218,7 +218,7 @@ func DhcpHelperFunc(xHostname string, xDUIDs []string, xIAIDs []uint32) []payloa rHostname := []rune(xHostname) if len(rHostname) < 6 { // 2+4 - // fallback: nimm letzte zwei Oktette 0.0 + fmt.Println("DhcpHelperFunc::1") qCalculatedIPv4 := Ipv4Octets[0] + "." + Ipv4Octets[1] + ".0.0" qCalculatedIPv6, _ := embedIPv4(qCalculatedIPv4) return []payloadHelper{{ @@ -233,6 +233,7 @@ func DhcpHelperFunc(xHostname string, xDUIDs []string, xIAIDs []uint32) []payloa IAID: "0", }} } + fmt.Println("DhcpHelperFunc::2") qDUID := firstOrEmpty(xDUIDs) qSegment1 := string(rHostname[2:4]) @@ -275,6 +276,7 @@ func getDhcp() []payloadHelper { for _, b := range cp { result = append(result, DhcpHelperFunc(b.Hostname, b.DUIDs, b.IAIDs)...) } + fmt.Println("getDhcp:Result::", result) return result } @@ -285,10 +287,12 @@ func register(w http.ResponseWriter, r *http.Request) { } var p payload if err := json.NewDecoder(r.Body).Decode(&p); err != nil { + fmt.Println("register:NewDecoder::ungültiges JSON") http.Error(w, "ungültiges JSON", http.StatusBadRequest) return } if p.Hostname == "" { + fmt.Println("register:Hostname::hostname fehlt") http.Error(w, "hostname fehlt", http.StatusBadRequest) return } @@ -447,6 +451,7 @@ func convertRange(start, end string) ([]addrPair, error) { func embedIPv4(ipv4 string) (string, error) { ip := net.ParseIP(ipv4).To4() if ip == nil { + fmt.Printf("%s ist keine gültige IPv4-Adresse", ipv4) return "", fmt.Errorf("%s ist keine gültige IPv4-Adresse", ipv4) } hi := uint16(ip[0])<<8 | uint16(ip[1])