* dnsfilter: refactor: a simple approach to convert Reason to string
This commit is contained in:
parent
a9fbb93f0f
commit
b66e370ffc
|
@ -133,6 +133,23 @@ const (
|
|||
FilteredSafeSearch
|
||||
)
|
||||
|
||||
func (i Reason) String() string {
|
||||
names := []string{
|
||||
"NotFilteredNotFound",
|
||||
"NotFilteredWhiteList",
|
||||
"NotFilteredError",
|
||||
"FilteredBlackList",
|
||||
"FilteredSafeBrowsing",
|
||||
"FilteredParental",
|
||||
"FilteredInvalid",
|
||||
"FilteredSafeSearch",
|
||||
}
|
||||
if uint(i) >= uint(len(names)) {
|
||||
return ""
|
||||
}
|
||||
return names[i]
|
||||
}
|
||||
|
||||
type dnsFilterContext struct {
|
||||
stats Stats
|
||||
dialCache gcache.Cache // "host" -> "IP" cache for safebrowsing and parental control servers
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// Code generated by "stringer -type=Reason"; DO NOT EDIT.
|
||||
|
||||
package dnsfilter
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _Reason_name = "NotFilteredNotFoundNotFilteredWhiteListNotFilteredErrorFilteredBlackListFilteredSafeBrowsingFilteredParentalFilteredInvalidFilteredSafeSearch"
|
||||
|
||||
var _Reason_index = [...]uint8{0, 19, 39, 55, 72, 92, 108, 123, 141}
|
||||
|
||||
func (i Reason) String() string {
|
||||
if i < 0 || i >= Reason(len(_Reason_index)-1) {
|
||||
return "Reason(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Reason_name[_Reason_index[i]:_Reason_index[i+1]]
|
||||
}
|
Loading…
Reference in New Issue