mirror of https://github.com/0xERR0R/blocky.git
PR notes & linter
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
This commit is contained in:
parent
0a9df2f181
commit
8eff14fee0
|
@ -52,7 +52,8 @@ func (cache stringMap) contains(searchString string) bool {
|
||||||
if idx < searchBucketLen {
|
if idx < searchBucketLen {
|
||||||
blockRule := cache[searchLen][idx*searchLen : idx*searchLen+searchLen]
|
blockRule := cache[searchLen][idx*searchLen : idx*searchLen+searchLen]
|
||||||
if blockRule == normalized {
|
if blockRule == normalized {
|
||||||
log.PrefixedLog("stringMap").Debugf("block rule '%s' matched with '%s'", blockRule, searchString)
|
log.PrefixedLog("string_map").Debugf("block rule '%s' matched with '%s'", blockRule, searchString)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,7 @@ func (cache regexCache) elementCount() int {
|
||||||
func (cache regexCache) contains(searchString string) bool {
|
func (cache regexCache) contains(searchString string) bool {
|
||||||
for _, regex := range cache {
|
for _, regex := range cache {
|
||||||
if regex.MatchString(searchString) {
|
if regex.MatchString(searchString) {
|
||||||
log.PrefixedLog("regexCache").Debugf("regex '%s' matched with '%s'", regex, searchString)
|
log.PrefixedLog("regex_cache").Debugf("regex '%s' matched with '%s'", regex, searchString)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ func (n *parent) insert(key string, split SplitFunc) {
|
||||||
func (n *parent) hasParentOf(key string, split SplitFunc) bool {
|
func (n *parent) hasParentOf(key string, split SplitFunc) bool {
|
||||||
searchString := key
|
searchString := key
|
||||||
rule := ""
|
rule := ""
|
||||||
|
|
||||||
for {
|
for {
|
||||||
label, rest := split(key)
|
label, rest := split(key)
|
||||||
rule = strings.Join([]string{label, rule}, ".")
|
rule = strings.Join([]string{label, rule}, ".")
|
||||||
|
@ -144,8 +145,9 @@ func (n *parent) hasParentOf(key string, split SplitFunc) bool {
|
||||||
if matched {
|
if matched {
|
||||||
rule = strings.Join([]string{child.String(), rule}, ".")
|
rule = strings.Join([]string{child.String(), rule}, ".")
|
||||||
rule = strings.Trim(rule, ".")
|
rule = strings.Trim(rule, ".")
|
||||||
log.PrefixedLog("Trie").Debugf("wildcard block rule '%s' matched with '%s'", rule, searchString)
|
log.PrefixedLog("trie").Debugf("wildcard block rule '%s' matched with '%s'", rule, searchString)
|
||||||
}
|
}
|
||||||
|
|
||||||
return matched
|
return matched
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue