goipgrep: refactor into module; pure-Go ping/resolve; cache+CI; drop binary

This commit is contained in:
tobias
2026-02-17 09:26:30 +01:00
parent 27760b0bf1
commit a931be4707
20 changed files with 1214 additions and 376 deletions

View File

@@ -0,0 +1,36 @@
package extract
import (
"context"
"strings"
"testing"
)
func TestGrepIPv4(t *testing.T) {
in := "a 1.2.3.4 b 999.2.3.4 c\nx 10.0.0.1 y"
var got []string
err := Grep(context.Background(), strings.NewReader(in), Options{Mode: ModeIP}, func(s string) {
got = append(got, s)
})
if err != nil {
t.Fatalf("Grep: %v", err)
}
// Candidate matcher intentionally returns 999.2.3.4 too; validation happens elsewhere.
if len(got) != 3 {
t.Fatalf("got %d matches: %#v", len(got), got)
}
}
func TestGrepMAC(t *testing.T) {
in := "aa:bb:cc:dd:ee:ff aabb.ccdd.eeff 00-11-22-33-44-55"
var got []string
err := Grep(context.Background(), strings.NewReader(in), Options{Mode: ModeMAC}, func(s string) {
got = append(got, s)
})
if err != nil {
t.Fatalf("Grep: %v", err)
}
if len(got) != 3 {
t.Fatalf("got %d matches: %#v", len(got), got)
}
}