2018-08-20 03:57:06 -04:00
|
|
|
package strmatcher
|
|
|
|
|
|
|
|
type FullMatcherGroup struct {
|
2020-08-11 01:31:04 -04:00
|
|
|
matchers map[string][]uint32
|
2018-08-20 03:57:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *FullMatcherGroup) Add(domain string, value uint32) {
|
|
|
|
if g.matchers == nil {
|
2020-08-11 01:31:04 -04:00
|
|
|
g.matchers = make(map[string][]uint32)
|
2018-08-20 03:57:06 -04:00
|
|
|
}
|
|
|
|
|
2020-08-11 01:31:04 -04:00
|
|
|
g.matchers[domain] = append(g.matchers[domain], value)
|
2018-08-20 03:57:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *FullMatcherGroup) addMatcher(m fullMatcher, value uint32) {
|
|
|
|
g.Add(string(m), value)
|
|
|
|
}
|
|
|
|
|
2020-08-11 01:31:04 -04:00
|
|
|
func (g *FullMatcherGroup) Match(str string) []uint32 {
|
2018-08-20 03:57:06 -04:00
|
|
|
if g.matchers == nil {
|
2020-08-11 01:31:04 -04:00
|
|
|
return nil
|
2018-08-20 03:57:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return g.matchers[str]
|
|
|
|
}
|