32-incorporate-dns

Incorporated a DNS server. A DNS server can be run to resolve host
names.
This commit is contained in:
Tim Beatham
2023-11-24 15:04:07 +00:00
parent f28ed8260d
commit d1a74a7b95
5 changed files with 164 additions and 2 deletions

19
pkg/lib/regex.go Normal file
View File

@@ -0,0 +1,19 @@
package lib
import "regexp"
func MatchCaptureGroup(pattern, payload string) map[string]string {
patterns := make(map[string]string)
expr := regexp.MustCompile(pattern)
match := expr.FindStringSubmatch(payload)
for i, name := range expr.SubexpNames() {
if i != 0 && name != "" {
patterns[name] = match[i]
}
}
return patterns
}