mirror of
https://github.com/tim-beatham/smegmesh.git
synced 2025-08-18 08:59:45 +02:00
32-incorporate-dns
Incorporated a DNS server. A DNS server can be run to resolve host names.
This commit is contained in:
19
pkg/lib/regex.go
Normal file
19
pkg/lib/regex.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user